getToken() failed. Status BAD_AUTHENTICATION error
Asked Answered
E

16

92

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.

Emplane answered 13/3, 2016 at 5:49 Comment(3)
Why there are so many up votes, but no checked answer? What is the solution anyway?Hawn
I am facing this problem too. What is the solution?Aerometeorograph
thanks for sharing your issue. it was helpful for meCopenhaver
C
4

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 .

Complaisance answered 9/7, 2017 at 17:44 Comment(6)
What exactly do you mean by saying "wrong credentials", because the "google-services.json" contains a lot informationsWreathe
as I said I just got a new google-services.json file and replaced it.Complaisance
The currently 'google-services.json' that I use it works fine when I test it on the emulator, but when I try it on a physical device I get the "BAD_AUTHENTICATION" error, that's why I'm confused, I'm not sure if I should generate a new one.Wreathe
it seems my answer wouldn't work for you. but you should always test google-services on physical devices. it is even possible that emulator haven't read everything on file.Complaisance
I think Google's documentation is not good enough and not clear enough to understand how to properly setup the accounts and how to integrate Google Drive.Wreathe
it really isn't good enough but if your app is not in production yet deleting and resubmitting the google-services.json will cause no problemComplaisance
S
4

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.

Soak answered 23/7, 2019 at 22:41 Comment(0)
R
2

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.

Respiration answered 14/3, 2017 at 7:46 Comment(0)
C
2

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

Coats answered 28/1, 2021 at 1:41 Comment(1)
getting this repeated now on old galaxy tab 2 test device until it crashes: Auth: [GoogleAccountDataServiceImpl] getToken() -> BAD_AUTHENTICATION. Account: <ELLIDED:XXXXXXXXXX>, App: com.google.android.gms, Service: oauth2:googleapis.com/auth/login_manager. updating and clearing play services data hasn't helped. shows as: libc.so (Missing BuildId 4a41edc48218b940fbd9785bf4e4abfd) error on crashylitics. I don't use OAuth2 APIs the link mentions.Customary
E
2

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.

Etesian answered 25/10, 2021 at 20:37 Comment(2)
it's working on me as magic. thank a lotCopenhaver
Yep, this worked for me too. A lot of other answers mention things like "I put all my code in a new project", "I restarted my phone", etc and I think they're all basically just resetting the app so a re-install is the best solution imo.Nonaligned
F
1

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.

Florid answered 1/6, 2017 at 4:2 Comment(0)
X
1

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

Xantho answered 12/6, 2018 at 4:24 Comment(0)
A
1

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

Admix answered 23/1, 2019 at 4:35 Comment(0)
R
0

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 .

Redfaced answered 11/6, 2017 at 8:17 Comment(0)
P
0

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'

Puffery answered 3/6, 2019 at 20:39 Comment(0)
M
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.

Montford answered 2/8, 2020 at 4:33 Comment(0)
P
0

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

Pressure answered 1/9, 2020 at 3:20 Comment(0)
H
0

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.

Hagi answered 16/9, 2020 at 10:50 Comment(0)
K
0

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

Kathe answered 28/7, 2022 at 15:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Topeka
L
0

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

Leonardo answered 17/12, 2022 at 13:1 Comment(2)
I had also checked the webClientId required to configure the Google SignIn package. My webClientId was already correct.Leonardo
I had also checked if the fingerprint of my keystore was correctly set on Firebase Console.Leonardo
D
0

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.

Daystar answered 2/3, 2024 at 17:56 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.