Following the android guidelines to integrate Google Sign in with credentials api
Google Sign in with credentials manager
val credentialManager = CredentialManager.create(context)
val googleIdOption: GetSignInWithGoogleOption =
GetSignInWithGoogleOption.Builder("web-client-id here")
.build()
val request: GetCredentialRequest =
GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
coroutineScope.launch {
try {
val result = credentialManager.getCredential(
request = request,
context = context,
)
handleGoogleLoginResult(result)
} catch (t: Throwable) {
Log.d(TAG, t.message.toString())
}
}
I receive this error:
[16] Account reauth failed.
with type
GetCredentialException.TYPE_USER_CANCELED
The weird part is that in a test project this works with the same keys.
Anyone has encountered this issue before?
Note i use this in KMM project and compose
Edit: 31/07/2024
I found a solution
I had provided wrong sha-1 in google credentials. My project has a lot of modules so i accidentaly provided the sha-1 of another module
For anyone coming across this who is using Flutter and Google / Firebase Auth and they encounter this when they go from local device / emulator testing to Google Play, this occurs because the SHA1 fingerprint is now different as Google Play takes care of signing your app for distribution for Play Store.
Solution - Get the new SHA1:
Go to Play store and select Your App
Go to Test and Release
Go to App Integrity
Scroll to Play App Signing (click settings to the right of the title)
Copy the SHA1 fingerprint
Go to Firebase Project Settings or Google Auth console where you define your SHA certificate fingerprints and add the new SHA1
Gets me every time.
In my case, this issue was happening because I was using a testing project (instead of trying to implement it directly on my game), and this testing project I created with a different package name than the one used in the Google Cloud (Android Client Id).
I'm pretty sure the different SHA-1 was also an issue, but I started using the real project keystore in my testing project when trying to find the reason for [16] Account reauth failed. and have not tested again without the keystore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With