Google-signin: IdToken always null

Created on 15 Aug 2016  路  9Comments  路  Source: react-native-google-signin/google-signin

After calling:

GoogleSignin.configure({
    webClientId: '<My-Client-Id>'
    offlineAccess: true
})

I then call GoogleSignin.signIn() and the user returned here always has a null IdToken.
I have made sure the the webClientId is the same as on the console (as per below screenshot), and matches up with whats in my google-services.json.

The other data is there (even a serverAuthCode), but not the IdToken. What am I doing wrong?

image

Most helpful comment

For those of you who have the same issue as me I managed to figure this out.

Setting offlineAccess to true provides you with the serverAuthCode to use server-side, but no longer returns the idToken. If you wish to retrieve the idToken, do not set the offlineAccess in configure (It defaults to false).

This is not mentioned in the docs so I am unsure if this is intended bevahior or a bug?

TLDR: remove the offlineAccess setting from the configure call to get the idToken.

All 9 comments

For those of you who have the same issue as me I managed to figure this out.

Setting offlineAccess to true provides you with the serverAuthCode to use server-side, but no longer returns the idToken. If you wish to retrieve the idToken, do not set the offlineAccess in configure (It defaults to false).

This is not mentioned in the docs so I am unsure if this is intended bevahior or a bug?

TLDR: remove the offlineAccess setting from the configure call to get the idToken.

@Lloydza Thanks a lot...

componentWillMount(){
   GoogleSignin.configure({
   scopes: ['https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive.metadata', 'https://www.googleapis.com/auth/drive.appdata', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/drive.metadata.readonly', 'https://www.googleapis.com/auth/drive.scripts', 'https://www.googleapis.com/auth/drive.readonly', 'https://www.googleapis.com/auth/drive.photos.readonly', 'https://www.googleapis.com/auth/drive.scripts'],

 ClientId :'8219......',

        });
    }

i have the same issue, i get idToken null. Any idea how to resolve this ?

@Lloydza I didn't configure offilineAccess, but I got a null idToken in android only. iOS got a response idToken with same code and configuration.

Any resolution?

@mattdamon108 I have not looked at this in a while, but if its not related to the offlineAccess setting I would say open a new issue and provide all the info. I believe the offlineAccess setting was fixed a couple years back.

For firebase project, when you enable google auth, there is field Web client ID under Web SDK configuration. Just copy that id to webClientId inside your configure() method

Using this solution worked for me

Same issue. Not using offlineAccess, but still got an idToken of null. Anyone with a solution? Getting the tokens from my google.services.json won't work either

idToken Note: idToken is not null only if you specify a valid webClientId. webClientId corresponds to your server clientID on the developers' console. It HAS TO BE of type WEB

Was this page helpful?
0 / 5 - 0 ratings