Sahar Malik
Sahar Malik

Reputation: 965

getToken() failed. Status BAD_AUTHENTICATION error

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.

Upvotes: 94

Views: 70414

Answers (16)

A. Abramov
A. Abramov

Reputation: 1865

After running adb logcat, I saw this issue had to do with one account I was logged in on the device for, and another the play store saved. Restarting and other solutions didn't work.

What worked was removing the accounts entirely from the device in the play store settings & device settings, and adding back the one I ended up using alone.

Upvotes: 0

ofundefined
ofundefined

Reputation: 3319

My problem was with Microsoft App Center.

We recently set our pipelines to send aab files to App Center, instead of apk files.

It seems that our bundle was resigned by App Center with some generated keystore. That's how App Center distributed apk files, even though our pipeline uploaded aab files.

In other words: even though our pipeline is using our own keystore to sign the aab bundle, in order to distribute through the App Center, after sending the aab to App Center, the App Center is creating universal apks with another generated keystore.

After rolling back our pipeline to send apk instead of aab, Google SignIn on our react-native app with firebase was working again.


"When you distribute Android Application Bundle (AAB), App Center generates a universal APK, signs it with a generated signing key, and distributes it to a device."

Source: https://learn.microsoft.com/en-us/appcenter/distribution/uploading

Upvotes: 0

Enes Kamil YILMAZ
Enes Kamil YILMAZ

Reputation: 11

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

Upvotes: 0

Greg Galloway
Greg Galloway

Reputation: 56

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.

Upvotes: 2

Dmitri R117
Dmitri R117

Reputation: 2832

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

Upvotes: 2

NevetsKuro
NevetsKuro

Reputation: 996

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.

Upvotes: 0

Ruhi Surve
Ruhi Surve

Reputation: 1

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

Upvotes: 0

Rishabh
Rishabh

Reputation: 1

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.

Upvotes: 0

Julia K
Julia K

Reputation: 591

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.

Upvotes: 4

Evismar Almeida
Evismar Almeida

Reputation: 1

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'

Upvotes: 0

HandyPawan
HandyPawan

Reputation: 1106

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

Upvotes: 1

John T
John T

Reputation: 1082

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

Upvotes: 1

Pouya Danesh
Pouya Danesh

Reputation: 1627

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 .

Upvotes: 4

Naman
Naman

Reputation: 39

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 .

Upvotes: 0

Jaz
Jaz

Reputation: 391

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.

Upvotes: 1

karanatwal.github.io
karanatwal.github.io

Reputation: 3673

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.

Upvotes: 2

Related Questions