iOS/Android signInWithGoogle with custom parameters, prompt for permissions not showing on iOS (scopes request), unable to get refresh token #433
-
Hi, I can't seem to make the sign in process with Google work with customParameters, on either iOS or Android. The end goal is to get a Google refresh token via the sign in process and be able to mint new access tokens to use different google APIs. My code is this: init: if (Capacitor.isNativePlatform()) {
return initializeAuth(getApp(), {
persistence: indexedDBLocalPersistence
});
} else {
return getAuth();
} call: FirebaseAuthentication.signInWithGoogle({
scopes: ['https://www.googleapis.com/auth/calendar.events', 'https://www.googleapis.com/auth/calendar.readonly'],
customParameters: [{key: 'access_type', value: 'offline'}, {key: 'prompt', value: 'consent'}]
}).then(async signInResult => {..}); logout: await FirebaseAuthentication.signOut().then(async () => {
const auth = getAuth();
await signOut(auth);
}) On web, it works always and, after the account selection and password screens, i'm shown the screen for additional scopes that i requested. On iOS: The screen for additional permissions is not shown, the sign in process skips it. If i check the access token that i receive (https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>) I'm only seeing the "userinfo.email", "userinfo.profile" and "openid" permissions (which makes sense given the screen with the permission request is not displayed). On Android: The screen is shown, however, even though a consent prompt is displayed, in firebase, a refresh token is not minted and the refresh token comes up as undefined. I can only guess that's because of the difference in how the authentication is being handled, or parameters are not sent to google in the initial request. I've looked at bug #209 but couldn't figure out if the feature was implemented or skipped. The bug is marked as resolved. I'm hoping that i'm wrong on this one and just messing up somewhere. Clarification of the use case: I understand that google will send the refresh token in the first auth response, only if access_type=offline is set and this is also dependent on the requested scopes. This will work and the user will be presented with the permissions request, and the cloud functions will receive the tokens, only on web, trough a popup authentication. This is the screen that's missing on iOS: Thank you for your time, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hey Mircea,
Yes, currently no |
Beta Was this translation helpful? Give feedback.
Hey Mircea,
The
scopes
option for Google Sign-In is currently only supported on Android and Web. But I could extend the support to iOS by now (see google/GoogleSignIn-iOS#23 (comment)). Feel free to create a feature request for this.Yes, currently no
customParameters
option is supported on Android and iOS for Google Sign-In.The reason is simply that I could not find a way so far.
On iOS, according to this issue, this is simply not possible yet: google/GoogleSignIn-iOS#112