Skip to content

Instantly share code, notes, and snippets.

@bkonkle
Last active December 15, 2022 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bkonkle/3acb11e246d16b325d63332e825a6943 to your computer and use it in GitHub Desktop.
Save bkonkle/3acb11e246d16b325d63332e825a6943 to your computer and use it in GitHub Desktop.
Electron Google Authentication - Part 1
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)
}
@SpyrosKoustas
Copy link

Hey, I am new to electron and I would like to add google auth to my project. Yet I cannot understand where to put the code snippets you are posting. Could you please help me?

Thanks in advance!

@akkravikumar
Copy link

@SpyrosKoustas put that code in main.js file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment