Error: Google id_token is not allowed to be used with this application. Firebase access fails after it was working

断了今生、忘了曾经 提交于 2019-12-12 08:12:48

问题


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:

  • DB is up and running. As a fact I can read when not logged (as I have defined by rules)
  • Sign-in method for Google is still ENABLED
  • My App is still registered the project configuration, including their SHA1 signature (for debug and release version)
  • I have confirmed the google-services.json file downloaded from configuration still match my app json file

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


回答1:


  1. You have to create Web-client Oauth 2.0 id here https://console.developers.google.com . After that you will have client id and secret
  2. Open https://console.firebase.google.com and goto Authentication -> Google -> Settings -> Web SDK and use clien od and secret you have got on the step 1.



回答2:


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.



来源:https://stackoverflow.com/questions/40450850/error-google-id-token-is-not-allowed-to-be-used-with-this-application-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!