Expo - ReactNative - AuthSession with Google does not work in standalone if responseType: "id_token"

Viewed 802

I am trying to authorise Google SignIn by using Google from expo-auth-session/providers/google";.

I need to get a specific response type which is id_token. In expo it works, Google returns all I need, but in Standalone, Google throws an error that such response type is unsupported. If I omit this property, all works fine, but I don't get an id_token, so it does not help me.

I wanted to know is there a workaround for this ?

2 Answers

Alternative 1 - Add responseType: 'id_token' in useAuthRequest

const [requestIdToken, responseIdToken, promptAsyncIdToken] =
    Google.useAuthRequest({
      responseType: 'id_token',
      androidClientId: GOOGLE_CLIENT_ID_ANDROID,
      iosClientId: GOOGLE_CLIENT_ID_IOS,
      expoClientId: GOOGLE_CLIENT_WEB_EXPO,
      scopes: ['profile', 'email'],
   })

Alternative 2 - Try changing your useAuthRequest by useIdTokenAuthRequest

Replacing useAuthRequest for `useIdTokenAuthRequest worked perfectly for me.

In the docs they only show useIdTokenAuthRequest for use with firebase, but it works with all the same arguments as the normal useAuthRequest method

Related