react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.12k stars 876 forks source link

After few successfull login attempts, stops working on Android #1164

Closed jankoJelic closed 1 year ago

jankoJelic commented 1 year ago

Hello everyone, I have implemented this library and it works perfectly on iOS, and on Android most of the time.

So it works and then, after a while, when a Google account is pressed:

Almost as if we run out of login attempts and enter a throttle and then it starts working again later.

I have tried various configuration changes and combinations on Android, like forceCodeForRefreshToken: true, (this one I thought could cause the issue, but it turns out when set either true or false it stops working at some point) offlineAccess: true/false

But every time it works for a while and then it stops to work, obviously without any code changes.

When the Google account is selected from modal, it just closes and nothing happens because I don't get any user info, including idToken which I need.

Environment

Did anyone experience any similar issues?

keshk26 commented 1 year ago

I am also getting this error. It works fine in my debug environment but fails on my release build. I have followed tips for troubleshooting such as adding the SHA-1 key to google.services.json and adding the webClientId as well as androidClientId. I am not sure what else I can do. Is it an issue with this library or with the google project configuration?

jankoJelic commented 1 year ago

I really don't know, tried with usesClearTextTraffic=true and some other stuff it was working flawlessly on apks, released a new build and still fails in Android. iOS is fine all the time

keshk26 commented 1 year ago

Here is what fixed signin for me: RN Version: 0.70.6 @react-native-google-signin/google-signin: 9.02 play-services-auth: 19.2.0

  1. GoogleSignin.configure only has the iOS and Android client ID. No web client ID.
  2. I added the android SHA-1 key to my Firebase project. Then I downloaded a new google-services.json and replaced my existing one.
  3. I was also using the wrong client key. Make sure the client ID used in GoogleSignin.configure is the same as the key used in the google-services.json.
jankoJelic commented 1 year ago

Do you use androidClientId or webClientId field in GoogleSignIn.configure() payload for the app on the store ? Do you have a different clientId for apk and aab ?

Philip-Smyth commented 1 year ago

@jankoJelic Strangely using webclientid instead of webClientId seems to make a successful call to firebase, the downside however is that idToken then seems to return null. However it might be a step in the right direction

jankoJelic commented 1 year ago

I actually got it working by recreating everything with Firebase, with new google-services.json

bweston92 commented 6 months ago

@Philip-Smyth did you manage to resolve the idToken being null?