I'm using Google SignIn and then authenticate on Firebase using signInWithCredential
, passing the Google credentials.
I followed all the procedures, and everything was working! And suddenly it stops working. I went to a previous working code and it still fails. So it seems something happened with the database configuration.
In Firebase DB I already checked:
After Google login finish Ok, the error message is as follows as I get from my try-catch with task.getException in the listener:
com.google.firebase.FirebaseException: An internal error has occurred. [ Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is XXXXX-XXXXX.apps.googleusercontent.com, which is not authorized to be used in the project with project_number: XXXXX. ]
at com.google.android.gms.internal.zzago.zzew(Unknown Source)
at com.google.android.gms.internal.zzagl$zzg.zza(Unknown Source)
at com.google.android.gms.internal.zzagw.zzex(Unknown Source)
at com.google.android.gms.internal.zzagw$zza.onFailure(Unknown Source)
at com.google.android.gms.internal.zzagr$zza.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
(I changed my project info to XXXX)
What else could have changed in the Firebase configuration? Please help!
Edit: SOLVED, as described below. You need to also take a look at the Google API console at https://console.developers.google.com/apis/credentials
The custom JWT returned from your server can then be used by a client device to authenticate with Firebase (iOS+, Android, web). Once authenticated, this identity will be used when accessing other Firebase services, such as the Firebase Realtime Database and Cloud Storage.
Because Firebase ID tokens are stateless JWTs, you can determine a token has been revoked only by requesting the token's status from the Firebase Authentication backend. For this reason, performing this check on your server is an expensive operation, requiring an extra network round trip.
The access tokens can be generated using a service account with proper permissions to your Realtime Database. Clicking the Generate New Private Key button at the bottom of the Service Accounts section of the Firebase console allows you to easily generate a new service account key file if you do not have one already.
An ID token is available when a Credential object's user ID matches the user ID of a Google account that is signed in on the device. To sign in with an ID token, first retrieve the ID token with the getIdTokens method. Then, send the ID token to your app's backend.
Sounds like your sign-in methods have changed. You need to go into the firebase authentication page and make sure that google sign in is still allowed.
Go to Firebase Console -> Authentication -> Sign-in method and in the sign in providers make sure that Google is enabled.
Also, you can do:
Get your web client ID and take note of both the client ID and secret.
Input this Client ID into your Firebase project’s configuration:
Go to the Firebase console at https://console.firebase.google.com Open the Auth section Under Sign-In methods, open the Google configuration, and add the values under the Web SDK configuration section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With