Skip to content

Authenticate users with Sign in with Google GetCredentialException:During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential.  #94

@zhangwenxiang26

Description

@zhangwenxiang26

dependent Sdk Version:
implementation "androidx.credentials:credentials:1.3.0-rc01"
implementation "androidx.credentials:credentials-play-services-auth:1.3.0-rc01"
implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1"

Test model:
OPPO PDKM00 Android12

Problem occurred:
GetCredentialException,
During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential.
android.credentials.GetCredentialException.TYPE_NO_CREDENTIAL

Operation steps when a problem occurs:

Step 1:

Open phone settings->User and Account->Password and account Delete Google account

Step 2:

Refer to the official documentation to log in to Google
https://developer.android.com/identity/sign-in/credential-manager-siwg#siwg-button

The code is as follows:

private var mCm: CredentialManager? = null
fun initLogin(activity : FragmentActivity?){
mCm = CredentialManager.create(this)
}

fun login(activity : FragmentActivity?){
activity?.apply {
val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(true)
.setServerClientId(serviceClientId)
.setAutoSelectEnabled(true)
.build()

        val request: GetCredentialRequest = GetCredentialRequest.Builder()
            .addCredentialOption(googleIdOption)
            .build()

        lifecycleScope.launch {
            try {
                val result = mCm?.getCredential(
                    request = request,
                    context = this@apply,
                )
                handleSignIn(result,this@apply)
            } catch (e: GetCredentialException) {
                **// During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential.**
                handleFailure(e)
                **loginAgain(activity)**
            }
        }
    }

}

fun loginAgain(activity : FragmentActivity?){

    activity?.apply {
        val googleIdOption: GetGoogleIdOption = GetGoogleIdOption.Builder()
            **.setFilterByAuthorizedAccounts(false)**
            .setServerClientId(defaultServiceClientId)
            .build()

        val request: GetCredentialRequest = GetCredentialRequest.Builder()
            .addCredentialOption(googleIdOption)
            .build()

        lifecycleScope.launch {
            try {
                val result = mCm?.getCredential(
                    request = request,
                    context = this@apply,
                )
                handleSignIn(result,this@apply)
            } catch (e: GetCredentialException) {
                 **// During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential.**
                
            }
        }
    }
}

Expected results:
If none are found, prompt the user to sign up with their Google Account using setFilterByAuthorizedAccounts(false);
pop-up interface for entering Google account:


Actual results:
Following the instructions in the document,
If no saved credentials are found (no Google Accounts returned by getGoogleIdOption), prompt your user to sign up. First, check if setFilterByAuthorizedAccounts(true) to see if any previously used accounts exist. If none are found, prompt the user to sign up with their Google Account using setFilterByAuthorizedAccounts(false);

an error still occurs,No pop-up interface for entering Google account:
exception occurred GetCredentialException,
During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential;
android.credentials.GetCredentialException.TYPE_NO_CREDENTIAL;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions