Код: Выделить всё
IDE: Android Studio
Language and framework: kotlin, Jetpack compose
Java version: 11
Gradle sdk info:
minSdk = 24
targetSdk = 35
versionCode = 1
versionName = "1.0"
compileSdk = 35
Emulator: Pixel 7 Pro
Код: Выделить всё
private val coroutineScope = CoroutineScope(Dispatchers.Main)
private val googleIdOption: GetSignInWithGoogleOption by lazy {
GetSignInWithGoogleOption.Builder(serverClientId =
context.getString(R.string.google_login_web_client_id))
.setNonce(generateNonce())
.build()
}
private val credentialManager by lazy {
CredentialManager.create(context)
}
fun signInWithGoogle(onSuccess: (String) -> Unit, onError: (Throwable) -> Unit) {
coroutineScope.launch {
val request: GetCredentialRequest = GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build()
try {
val result = credentialManager.getCredential(
request = request,
context = context
)
handleSignIn(result, onSuccess)
} catch (e: GetCredentialException) {
onError(e)
}
}
}
Код: Выделить всё
androidx.credentials.exceptions.GetCredentialCancellationException: [16] Account
reauth failed.
at
androidx.credentials.CredentialProviderFrameworkImpl.convertToJetpackGetException$credentials_release(CredentialProviderFrameworkImpl.kt:310)
at androidx.credentials.CredentialProviderFrameworkImpl$onGetCredential$outcome$2.onError(CredentialProviderFrameworkImpl.kt:172)
at androidx.credentials.CredentialProviderFrameworkImpl$onGetCredential$outcome$2.onError(CredentialProviderFrameworkImpl.kt:160)
at android.credentials.CredentialManager$GetCredentialTransport.lambda$onError$2(CredentialManager.java:820)
at android.credentials.CredentialManager$GetCredentialTransport.$r8$lambda$_rg2Q59c21DJrPoh5aAnwNR78wQ(Unknown Source:0)
at android.credentials.CredentialManager$GetCredentialTransport$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at androidx.credentials.CredentialManager$$ExternalSyntheticLambda0.execute(D8$$SyntheticClass:0)
at android.credentials.CredentialManager$GetCredentialTransport.onError(CredentialManager.java:819)
at android.credentials.IGetCredentialCallback$Stub.onTransact(IGetCredentialCallback.java:121)
at android.os.Binder.execTransactInternal(Binder.java:1505)
at android.os.Binder.execTransact(Binder.java:1444)
Код: Выделить всё
GetCredentialException.TYPE_USER_CANCELED
Подробнее здесь: https://stackoverflow.com/questions/792 ... -account-r