@@ -13,6 +13,8 @@ import {initTracking} from 'web/lib/service/analytics'
1313import WebPush from "web/lib/service/web-push" ;
1414import AndroidPush from "web/lib/service/android-push" ;
1515import { unauthedApi } from "common/util/api" ;
16+ import { GoogleAuthProvider , signInWithCredential } from "firebase/auth" ;
17+ import { auth } from "web/lib/firebase/users" ;
1618
1719// See https://nextjs.org/docs/basic-features/font-optimization#google-fonts
1820// and if you add a font, you must add it to tailwind config as well for it to work.
@@ -87,9 +89,21 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
8789 return ;
8890 }
8991
90- const { result} = await unauthedApi ( 'auth-google' , { code, codeVerifier} )
91- console . log ( '/auth-google result' , result ) ;
92- // google sign in
92+ try {
93+ const { result} = await unauthedApi ( 'auth-google' , { code, codeVerifier} )
94+ const googleTokens = result . tokens
95+ console . log ( '/auth-google tokens' , googleTokens ) ;
96+ // Create a Firebase credential from the Google tokens
97+ const credential = GoogleAuthProvider . credential ( googleTokens . id_token , googleTokens . access_token )
98+ // Sign in with Firebase using the credential
99+ const userCredential = await signInWithCredential ( auth , credential )
100+ console . log ( 'Creds:' , userCredential )
101+ console . log ( 'Firebase user:' , userCredential . user )
102+ return userCredential
103+ } catch ( e ) {
104+ console . error ( 'Error during OAuth flow:' , e ) ;
105+ return
106+ }
93107 }
94108
95109 // Expose globally for native bridge
0 commit comments