getToken() failed. Status BAD_AUTHENTICATION error
AndroidGoogle Play-ServicesAndroid Problem Overview
I've found the following error when running my android application in android studio. app couldn't get installed on my device because of this error. Didn't find the solution :( please help
> Auth: [GoogleAccountDataServiceImpl] getToken() failed.
> Status BAD_AUTHENTICATION,
> Account:
Android Solutions
Solution 1 - Android
I had the same issue what helped me was that I had wrong credentials in my google-services.json
file and after getting a new file my problem was fixed.
in the process of resolving this issue I also updated my google play services but I do not think this is necessary .
Solution 2 - Android
I got this error when tried to install app directly from Android Studio.
It was due to certificate mismatch, since I used release certificate for setting up the app in Play Console, while Android Studio signs the app with debug certificate by default.
Installing app via adb resolved the error.
https://developers.google.com/games/services/android/quickstart#step_4_test_your_game
> Make sure to run an APK that you exported and signed with a > certificate that matches one of the certificates you used during the > application setup in Google Play Console.
Solution 3 - Android
I have the same problem some days ago. I just compile my whole code in a new project and Problem Solved!!.
Don't know what was the real problem. There is an issue filed here, with no solution.
Solution 4 - Android
I updated Google Play Services on my phone and stopped receiving the same error. I am importing com.google.android.gms:play-services-cast:9.6.1 and analytics:9.6.1. Not sure if the version running on the device was too low but problem is now resolved but not sure how to prevent this error for users running older versions of Google Play Services.
Solution 5 - Android
Tested the other solutions but nothing worked. Rebooted the device and error was gone.
Solution 6 - Android
If you using firebase server, As per the firebase updation if you give phone number authentication put your country code before contact number it is mendetory. example - +91 9999998888
Solution 7 - Android
There are several reasons you can get that message:
-
The account you are trying to log on with needs to be re-authenticated on the phone (try a different account)
-
The gms:play-services version is out of date (needs to be 15+ as of Jan 2021)
-
Your app fingerprint is not the right one. You need one for dev builds, different one for prod -- which is different based on how you sign (do you have the final publish key, or does Play store re-sign with the final publish key?)
Follow the Google tutorial and get their stand-alone project, it should take 20 min, and check your setup there. If you are running it with all the right accounts it should work. Then go back to your app.
https://developers.google.com/identity/sign-in/android/start
Solution 8 - Android
This happened to me, auth errors in ADB, among them:
android Warn Auth [GoogleAuthUtil] GoogleAuthUtil
Because, like mentioned above, I had a debug build running on phone previously. So I fully uninstalled the app on my phone, and the next [Build and Run] ran successfully.
Solution 9 - Android
Please try the App with new google credentials or even try creating the whole peoject on console og google play services if you have used it .
Solution 10 - Android
In my case it was a dependency version problem. I had to update the auth dependency for firebase to the latest one: implementation 'com.google.firebase:firebase-auth:17.0.0'
Solution 11 - Android
Here is my take towards this problem:
-
You may be using a single email to try and log in to google. It may be possible you might have changed the password of the particular email in the recent past. Make sure u remove your google-email from your phone/emulator. When u re-run your application, you will be asked to enter both email and password credentials.
-
Check if your credentials.json is still valid. Sometimes its possible that your client ID might be removed/corrupted if you have not used your android application for a long time. Make a new one and dont forget to copy-paste it in app folder of Android Project view.
PS: I am new to Android Studio and writing answers on stackoverflow in general. If you are reading this comment please let me know what improvements i can make while answering questions in the future.
Solution 12 - Android
I copied and ran the code in a different project that had priorly worked on simple DB operations of Firebase. Probably it already had the authentication files in place so launching the app was solved there
Solution 13 - Android
Mostly your token has gone bad. And needs a new one. Go to project database > settings > General > download Json file and replace it with the one in the local project directory.