getToken() failed. Status BAD_AUTHENTICATION error

Viewed 52608

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: , App:com.android.vending, Service: androidmarket com.google.android.gms.auth.be.account.b.d: Long live credential not available.

14 Answers

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.

Tested the other solutions but nothing worked. Rebooted the device and error was gone.

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

There are several reasons you can get that message:

  1. The account you are trying to log on with needs to be re-authenticated on the phone (try a different account)

  2. The gms:play-services version is out of date (needs to be 15+ as of Jan 2021)

  3. 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

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.

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'

Here is my take towards this problem:

  1. 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.

  2. 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.

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

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.

I fixed this problem with updating fingerprints (sha1 or sha256)

Related