Last active
December 15, 2022 11:31
-
-
Save bkonkle/3acb11e246d16b325d63332e825a6943 to your computer and use it in GitHub Desktop.
Electron Google Authentication - Part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {parse} from 'url' | |
import {remote} from 'electron' | |
import axios from 'axios' | |
import qs from 'qs' | |
const GOOGLE_AUTHORIZATION_URL = 'https://accounts.google.com/o/oauth2/v2/auth' | |
const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token' | |
const GOOGLE_PROFILE_URL = 'https://www.googleapis.com/userinfo/v2/me' | |
export async function googleSignIn () { | |
const code = await signInWithPopup() | |
const tokens = await fetchAccessTokens(code) | |
const {id, email, name} = await fetchGoogleProfile(tokens.access_token) | |
const providerUser = { | |
uid: id, | |
email, | |
displayName: name, | |
idToken: tokens.id_token, | |
} | |
return mySignInFunction(providerUser) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@SpyrosKoustas put that code in main.js file