Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onGoogleSignInResult rerurn google user null,idtoken null #67

Open
bmw996 opened this issue Nov 9, 2024 · 6 comments
Open

onGoogleSignInResult rerurn google user null,idtoken null #67

bmw996 opened this issue Nov 9, 2024 · 6 comments

Comments

@bmw996
Copy link

bmw996 commented Nov 9, 2024

No description provided.

@mirzemehdi
Copy link
Owner

@bmw996 can you please attach more info? This can be related to some firebase misconfiguration, or not adding sha1 fingerprint in android side

@frankois944
Copy link

frankois944 commented Dec 18, 2024

Same thing here.

The error is here

GoogleAuthUiProvider {
override suspend fun signIn(filterByAuthorizedAccounts: Boolean): GoogleUser? {
return try {
getGoogleUserFromCredential(filterByAuthorizedAccounts = filterByAuthorizedAccounts)
} catch (e: NoCredentialException) {
if (!filterByAuthorizedAccounts) return handleCredentialException(e)
try {
getGoogleUserFromCredential(filterByAuthorizedAccounts = false)
} catch (e: GetCredentialException) {
handleCredentialException(e)
} catch (e: NullPointerException) {
null
}
} catch (e: GetCredentialException) {
handleCredentialException(e)
} catch (e: NullPointerException) {
null
}
}
private suspend fun handleCredentialException(e: GetCredentialException): GoogleUser? {
println("GoogleAuthUiProvider error: ${e.message}")
val shouldCheckLegacyAuthServices = when (e) {
is GetCredentialProviderConfigurationException -> true
is NoCredentialException -> true
is GetCredentialUnsupportedException -> true
else -> false
}
return if (shouldCheckLegacyAuthServices) {
checkLegacyGoogleSignIn()
} else {
null
}
}

handleCredentialException => androidx.credentials.exceptions.GetCredentialCancellationException: activity is cancelled by the user.

It happens just after selecting a user, the Google dialog is closed then the error is triggered.

With a project with up to date deps (kotlin 2.1.0 / Firebase 33.7.0 / Compose 1.7.1)

@gcaguilar
Copy link

Hey @mirzemehdi, I was able to reproduce the problem on an Android device with a Google account added. When I click the GoogleSignInButton, the account selection dialog appears. After selecting an account, the dialog disappears and an exception is thrown Idtoken is null.

@devenvoy
Copy link

devenvoy commented Jan 5, 2025

Same thing here.

The error is here

GoogleAuthUiProvider {
override suspend fun signIn(filterByAuthorizedAccounts: Boolean): GoogleUser? {
return try {
getGoogleUserFromCredential(filterByAuthorizedAccounts = filterByAuthorizedAccounts)
} catch (e: NoCredentialException) {
if (!filterByAuthorizedAccounts) return handleCredentialException(e)
try {
getGoogleUserFromCredential(filterByAuthorizedAccounts = false)
} catch (e: GetCredentialException) {
handleCredentialException(e)
} catch (e: NullPointerException) {
null
}
} catch (e: GetCredentialException) {
handleCredentialException(e)
} catch (e: NullPointerException) {
null
}
}
private suspend fun handleCredentialException(e: GetCredentialException): GoogleUser? {
println("GoogleAuthUiProvider error: ${e.message}")
val shouldCheckLegacyAuthServices = when (e) {
is GetCredentialProviderConfigurationException -> true
is NoCredentialException -> true
is GetCredentialUnsupportedException -> true
else -> false
}
return if (shouldCheckLegacyAuthServices) {
checkLegacyGoogleSignIn()
} else {
null
}
}

handleCredentialException => androidx.credentials.exceptions.GetCredentialCancellationException: activity is cancelled by the user.

It happens just after selecting a user, the Google dialog is closed then the error is triggered.

With a project with up to date deps (kotlin 2.1.0 / Firebase 33.7.0 / Compose 1.7.1)

i am also getting null token
project using Kotlin:2.1.0 / compose:1.7.1
@frankois944 have you found any solution?

@frankois944
Copy link

@devenvoy I didn't even go further as it was not critical for my project.

The other way is do it yourself by the swift/native way with a bridge. Take a look here for a quick bridge and the official firebase documentation .

@mirzemehdi
Copy link
Owner

as I see it looks like it is related to wrong web client id:

please check these solutions if it works for you:

https://stackoverflow.com/a/77732924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants