Google-signin: Error "unknown status code: 12501" when using clientID

Created on 8 Jan 2016  路  21Comments  路  Source: react-native-google-signin/google-signin

Without providing client Id to GoogleSignin.configure plugin works well. But when i pass this parameter, i get the "unknown status code: 12501". I learned that this error may come from wrong configuration, but...
The client Id i get from google developers console (New credentials -> OAuth ClientID -> Android). SHA-1 signing-certificate fingerprints specified correctly (fingerprint from ~/.android/debug.keystore matches to that specified in android/app/google-services.json and this key definitely used to sign my debug apk). Also client_id in google-services.json matches to that i pass to GoogleSignin.configure.
Any thoughts?

Android 6.0.1, [email protected], [email protected]

Most helpful comment

the non-obvious thing from Google documentation is that clientId has to be of type Web Application

from your google project console, on the API Manager -> Credentials page, select New credentials -> OAuth Client ID and make sure to select Web Application

the newly generated clientID is the one ;)

All 21 comments

I have exactly the same issue with the same configuration. I downgraded react-native-google-signin to 0.2.4, and I don't have 12501 error now, but accessToken is null....

the non-obvious thing from Google documentation is that clientId has to be of type Web Application

from your google project console, on the API Manager -> Credentials page, select New credentials -> OAuth Client ID and make sure to select Web Application

the newly generated clientID is the one ;)

@lesniakania have you tried clientid of type "Web application", as @devfd devfd said? This solution didn't help me :(

well that's weird, the sample app is working fine even with a clientId

check that:

  • clientId is of type 'Web application'
  • your application FQDN matches the one registered under Android API key in your google console

@vladvasyuk it partially worked for me.
Firslty I had issues with this line: https://github.com/apptailor/react-native-google-signin/blob/master/android/build.gradle#L21

I needed to change it to 0.17.0 as for some reason I had errors while using let { ListView } = React; syntax. It looked a little bit like React 0.18.0-rc would compile, but I have 0.17.0 in my app and can't get 0.18.0-rc because of lack of compatibilty with other libraries.

When I changed that and use Web application type of clientId, I finally managed to get accessToken. But firstly I think it's idToken, not accessToken, I changed also this in my local copy of react-native-google-signin, to use requestServerAuthCode and getServerAuthCode, it worked, but I'm not sure if it's still what I need.

In short - everything works for me fine for iOS but I still have issues with Android version. It looks like tokens returned by Android version are different than returned by iOS version.

@vladvasyuk Please see my pull request: https://github.com/apptailor/react-native-google-signin/pull/26
That was only change I needed in this library to get this working.

Additionally, I needed to update my app to react-native 0.18 (I have some problems with that, but upgrading node to 5.2.0 (npm 3.3.12) helped me).

If you don't want to upgrade react-native, you'd probably need to change this line to compile "com.facebook.react:react-native:0.17.0".

The flow of the sign in looks like this:

  1. Create client id of the type android, download google-services.json config file, put it to the android/app directory
  2. Create client id for web and use it in react-native-google-signin library init
  3. You should get basic user info + idToken and authServerCode
  4. If you have separate backend server

    • if you just want to login user, without using later Google API, just send idToken to the server and verify user identity from there

    • if you want to use Google API, send authServerCode to your server and exchange it along with your secret for the accessToken

I'm happy to help you more on priv if you want - slimak.[email protected]

These resources helped me:

I still have this issue and getting 12501 error code. @lesniakania I tried your code from pull request, it didn't help. I tried example from this project, set up all client id (android and web app) and it also didn't work. I have tried different versions of react native and this package. No result.

I tried completely native example from google https://github.com/googlesamples/google-services/tree/master/android/signin and it works fine, I can get server Auth Code.

I don't know how to fix it. maybe I need some special settings in gradle file ? Can anyone share his working example ?

Many thanks

when trying the sample app included in this project, simply:
cd example; react-native run-android

and you are good to go. the client id is already configured correctly.

please confirm everything is working as expected.

also you can set up a public github repo with your App so that we can help you better

Yes, I did as you wrote.
cd example
npm install
react-native run-android

and got ERROR signin in Object {error: "unknown status code: 12501", code: 12501}

alright strange. on what device you are testing ?

Maybe try

rm -rf android/build
rm -rf android/app/build

And also quit from your React packager console (and make sure that you don't have any zombie processes - ps aux | grep packager) before running react-native run-android

So I'm having the same issue now with 0.19. Do you end up having to create two sets of credentials and two clientIds? One for the android app (google_secrets.json) and another one for the oauth?

Yes, because that is how oauth flow should actually works.
The idea is that you have one set of credentials on the client (here, on Android side, you use client id in google-services.json).
You use this credentials to obtain temporary server authorization code which you can exchange for access token you'd need to actually use Google API.
But to obtain access token you need server auth code + secret. The idea is that you obtain this token using your backend server, where your secret is save.
So you send this temporary auth code to your backend server and exchange it along with secret for access token doing request to https://www.googleapis.com/oauth2/v4/token from your backend.
That's why second pair of credentials must be of 'web' type.

You can read more (here)[https://developers.google.com/identity/protocols/OAuth2ForDevices] and (here)[https://developers.google.com/identity/sign-in/android/offline-access].

I'm testing on different devices: LG G4 Android 6.0, Samsung Galaxy s4 android 5.1

@lesniakania Thanks, I have tried your solutions, but it didn't help.
I dont understand what I'm doing wrong. I have set up android and web app client id, downloaded google-services.json file. I guess maybe I have some errors in configuration, but don't know how to find it.

I have set up public repo on github with my test app https://github.com/ddzyndra/googleSignIn
Can you take a look on that and give some advice ?

@ddzyndra your google configuration seems to be off. you are missing API Keys. they are auto-created by the configuration wizzard.

Also your build.gradle should not include compile "com.google.android.gms:play-services-auth:8.3.0"

Please start again from a fresh install, carefully follow the instructions and you should be fine ;)

correct config

Thank you, @devfd very much for your help :) Yes, I have API Keys, I posted wrong screenshot. Did you get my example working? do you use debug or release key store?

Does it depend on node version ?

@ddzyndra sorry, I have crazy week, I will look at your code tomorrow evening.

sorry guys, it looks like I have found my problem. I changed the owner of .gradle file and ran react-native run-android without sudo. And it works now.

Thank you @devfd and @lesniakania for your help!

I'm getting this issue now. @ddzyndra how did changing the owner fix it and how do i go about doing that?

apologies, didnt restart my node server after doing all this... my issue is fixed

I had the same problem and here is the answer: http://stackoverflow.com/a/41413713/1498586

and this is sample code in github: https://github.com/mahdit83/FireBaseAuthDemo

Was this page helpful?
0 / 5 - 0 ratings