Google-signin: serverAuthCode: null and idToken: null

Created on 11 Jun 2019  路  3Comments  路  Source: react-native-google-signin/google-signin

I try to get the idToken from login but i get null for token and serverAuthCode.
I can login and get other user data but not idToken and serverAuthCode

For cofigure i use:

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'],
    ClientId:'myID',

  });

If i try to change from CliendId to webClientId i get error code 10 and i even cant login.

I am using
```
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'


ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 18
compileSdkVersion = 28
targetSdkVersion = 26
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "15.0.1" }


dependencies {
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:support-core-utils:28.0.0"
implementation project(':react-native-fcm')
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation project(':react-native-push-notification')
compile 'com.google.android.gms:play-services-auth:16.0.1'}
```

Most helpful comment

After 2 days trying to resolve this issue i figure out the problem. In the https://console.developers.google.com/apis/credentials copy oAuth client id if you have web client generated or create one web client and copy the oAuth client id to

GoogleSignin.configure({
    scopes: [ 'https://www.googleapis.com/auth/drive.photos.readonly'],
      webClientId:"oAuth client id",
       offlineAccess: true
  });

After that you will sign in and after you sign in you have to use one more method to get accessToken :

const currentUser = GoogleSignin.getTokens().then((res)=>{
                console.log(res.accessToken );
});

After that you will get the accessToken and use it .

All 3 comments

hi, yes i tried i even deleted the app from firebase consoleand also credentials in Apis and services and created new one and now i cant get login. I get [Error: DEVELOPER_ERROR] with code 10. I did the same procedures as first time. The thing is that i cant get the idToken to upload documents .

After 2 days trying to resolve this issue i figure out the problem. In the https://console.developers.google.com/apis/credentials copy oAuth client id if you have web client generated or create one web client and copy the oAuth client id to

GoogleSignin.configure({
    scopes: [ 'https://www.googleapis.com/auth/drive.photos.readonly'],
      webClientId:"oAuth client id",
       offlineAccess: true
  });

After that you will sign in and after you sign in you have to use one more method to get accessToken :

const currentUser = GoogleSignin.getTokens().then((res)=>{
                console.log(res.accessToken );
});

After that you will get the accessToken and use it .

Was this page helpful?
0 / 5 - 0 ratings