Comments (21)
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 ;)
from google-signin.
@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:
- Create client id of the type android, download
google-services.json
config file, put it to theandroid/app
directory - Create client id for web and use it in
react-native-google-signin
library init - You should get basic user info +
idToken
andauthServerCode
- 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 theaccessToken
- if you just want to login user, without using later Google API, just send
I'm happy to help you more on priv if you want - [email protected]
These resources helped me:
- https://developers.google.com/identity/protocols/OAuth2ForDevices
- https://developers.google.com/identity/sign-in/android/backend-auth
- https://developers.google.com/identity/sign-in/android/offline-access
from google-signin.
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
....
from google-signin.
@lesniakania have you tried clientid of type "Web application", as @devfd devfd said? This solution didn't help me :(
from google-signin.
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
from google-signin.
@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.
from google-signin.
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
from google-signin.
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
from google-signin.
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}
from google-signin.
alright strange. on what device you are testing ?
from google-signin.
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
from google-signin.
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?
from google-signin.
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].
from google-signin.
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 ?
from google-signin.
@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 ;)
from google-signin.
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 ?
from google-signin.
@ddzyndra sorry, I have crazy week, I will look at your code tomorrow evening.
from google-signin.
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!
from google-signin.
I'm getting this issue now. @ddzyndra how did changing the owner fix it and how do i go about doing that?
from google-signin.
apologies, didnt restart my node server after doing all this... my issue is fixed
from google-signin.
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
from google-signin.
Related Issues (20)
- missing dependencies HOT 2
- OneTap fails on web when 'sign-in prompts' are disabled HOT 4
- App crashing on iOS while tapping on Sign in with Google! HOT 4
- signInSilently gives error [Error: SIGN_IN_REQUIRED] HOT 8
- Unable to install sponsored version HOT 3
- Solution to issue #1176 (Supabase on iOS with Expo) HOT 2
- How to import isErrorWithCode HOT 2
- 11.0.0: CocoaPods could not find compatible versions for pod "ExpoAdapterGoogleSignIn": HOT 1
- [Website] Example links don't work HOT 2
- Include of non-modular header inside framework module 'GTMAppAuth.GTMAppAuthFetcherAuthorization': HOT 1
- (DEVELOPER_ERROR) Only in production Android HOT 1
- Tried to register two views with the same name RNGoogleSigninButton error
- I am not getting user's Birthday HOT 2
- AppAuth 1.7.0 will give 'No visible @interface for 'OIDAuthorizationResponse' declares the selector 'tokenExchangeRequestWithAdditionalParameters:' HOT 8
- no visible @interface for 'OIDAuthorizationResponse' declares the selector 'tokenExchangeRequestWithAdditionalParameters:' HOT 3
- Error: RN GoogleSignin native module is not correctly linked. Please read the readme, setup and troubleshooting instructions carefully. HOT 1
- Can't access your doc site HOT 4
- bridgeless mode HOT 2
- Remove scopes HOT 1
- The Swift pod `GTMAppAuth` depends upon `GTMSessionFetcher` and `AppAuth` HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-signin.