Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "unknown status code: 12501" when using clientID #22

Closed
vladvasyuk opened this issue Jan 8, 2016 · 21 comments
Closed

Error "unknown status code: 12501" when using clientID #22

vladvasyuk opened this issue Jan 8, 2016 · 21 comments

Comments

@vladvasyuk
Copy link

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, react-native@0.17.0, react-native-google-signin@0.3.0

@lesniakania
Copy link

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....

@devfd
Copy link
Contributor

devfd commented Jan 11, 2016

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 ;)

@devfd devfd closed this as completed Jan 11, 2016
@vladvasyuk
Copy link
Author

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

@devfd
Copy link
Contributor

devfd commented Jan 12, 2016

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

@lesniakania
Copy link

@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.

@lesniakania
Copy link

@vladvasyuk Please see my pull request: #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.ania@gmail.com

These resources helped me:

@ddzyndra
Copy link

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

@devfd
Copy link
Contributor

devfd commented Jan 29, 2016

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

@ddzyndra
Copy link

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}

@devfd
Copy link
Contributor

devfd commented Jan 29, 2016

alright strange. on what device you are testing ?

@lesniakania
Copy link

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

@haydenth
Copy link

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?

@lesniakania
Copy link

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].

@ddzyndra
Copy link

ddzyndra commented Feb 1, 2016

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 ?

@devfd
Copy link
Contributor

devfd commented Feb 2, 2016

@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

@ddzyndra
Copy link

ddzyndra commented Feb 3, 2016

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 ?

@lesniakania
Copy link

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

@ddzyndra
Copy link

ddzyndra commented Feb 4, 2016

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!

@seanscal
Copy link

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

@seanscal
Copy link

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

@mahdit83
Copy link

mahdit83 commented Jan 1, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants