This commit is contained in:
MartinBraquet
2025-10-30 13:20:27 +01:00
parent ccde6e4f4b
commit 213c56f945
2 changed files with 6 additions and 3 deletions

View File

@@ -76,7 +76,7 @@ export const GOOGLE_CLIENT_ID = WEB_GOOGLE_CLIENT_ID
* Authenticates a Firebase client running a webview APK on Android with Google OAuth.
*
* `https://accounts.google.com/o/oauth2/v2/auth?${params}` to get the code (in external browser, as google blocks it in webview)
* Redirects to `com.compassmeet:/auth` (in webview java main activity)
* Redirects to `com.compassmeet://auth` (in webview java main activity)
* 'https://oauth2.googleapis.com/token' to get the ID token (in javascript app)
* signInWithCredential(auth, credential) to set up firebase user in client (auth.currentUser)
*

View File

@@ -69,8 +69,11 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
console.log('Registering OAuth redirect listener for Android WebView')
window.addEventListener('oauthRedirect', async (event: any) => {
console.log('Received oauthRedirect event');
console.log('Received oauthRedirect event:', event.detail);
const url = new URL(event.detail);
const detail = typeof event.detail === 'string' ? JSON.parse(event.detail) : event.detail
console.log('OAuth data:', detail);
const url = new URL(detail);
const code = url.searchParams.get('code');
if (!code) {
@@ -87,7 +90,7 @@ function MyApp({Component, pageProps}: AppProps<PageProps>) {
client_id: GOOGLE_CLIENT_ID,
code,
code_verifier: codeVerifier!,
redirect_uri: 'com.compassmeet:/auth',
redirect_uri: 'com.compassmeet://auth',
grant_type: 'authorization_code',
}),
});