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

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

Open
zhangwenxiang26 opened this issue Aug 1, 2024 · 11 comments

Comments

@zhangwenxiang26
Copy link


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;

@DawnNguyenAhiho
Copy link

I'm facing this issue, too. Do you find any good solution. Thank you

@zhangwenxiang26
Copy link
Author

Trigger a Sign in with Google button flow
To trigger the Sign in with Google button flow, use [GetSignInWithGoogleOption]

Try using the following method:

fun loginAgain(activity : FragmentActivity?){

activity?.apply {
   val signInWithGoogleOption: GetSignInWithGoogleOption = GetSignInWithGoogleOption.Builder()
        .setServerClientId(defaultServiceClientId)
        .build()

    val request: GetCredentialRequest = GetCredentialRequest.Builder()
        .addCredentialOption(signInWithGoogleOption)
        .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.**
            
        }
    }
}

}

@DawnNguyenAhiho
Copy link

I've already used that GetSignInWithGoogleOption but some of my user can't login. Most of them don't have any problem, but some of them can't login

@niharika2810
Copy link
Contributor

Hey would you mind creating a bug for those users with all details required in that template? Please add version details, bug report, video recording, device details, api version used etc if you are able to reproduce. Sharing the bug link here : https://issuetracker.google.com/issues/new?component=1301097&template=1773864

This will help us test and verify the issue on these devices.

@7alma9z
Copy link

7alma9z commented Sep 30, 2024

I am facing the same issue any solution for this ?

androidx.credentials.exceptions.NoCredentialException: During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential.
at androidx.credentials.playservices.controllers.CredentialProviderBaseController$Companion.getCredentialExceptionTypeToException$credentials_play_services_auth_release(CredentialProviderBaseController.kt:110)
at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$resultReceiver$1$onReceiveResult$1.invoke(CredentialProviderBeginSignInController.kt:93)
at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$resultReceiver$1$onReceiveResult$1.invoke(CredentialProviderBeginSignInController.kt:93)
at androidx.credentials.playservices.controllers.CredentialProviderController.maybeReportErrorFromResultReceiver(CredentialProviderController.kt:159)
at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController.access$maybeReportErrorFromResultReceiver(CredentialProviderBeginSignInController.kt:56)
at androidx.credentials.playservices.controllers.BeginSignIn.CredentialProviderBeginSignInController$resultReceiver$1.onReceiveResult(CredentialProviderBeginSignInController.kt:91)
at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:8061)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:703)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

@niharika2810
Copy link
Contributor

Hi As mentioned above, please create a bug and provide all the details to deep dive :

Hey would you mind creating a bug for those users with all details required in that template? Please add version details, bug report, video recording, device details, api version used etc if you are able to reproduce. Sharing the bug link here : https://issuetracker.google.com/issues/new?component=1301097&template=1773864

@udev
Copy link

udev commented Oct 30, 2024

I had the same problem as the others. @zhangwenxiang26's solution was the only thing that worked. The API does not appear to account for the case where there is no device account available. Docs for NoCredentialsException suggest

Upon this exception, your app should navigate to use the regular app sign-up or sign-in screen.

but my current project only uses OAuth and Passkey for authentication. Samples aren't particularly clear on how to handle this scenario.

@SujithManjavana
Copy link

I am having the same issue. It was working fine till yesterday. But now I'm getting this error During begin sign in, failure response from one tap: 16: [28433] Cannot find a matching credential. on the same device.

@renaudboulard
Copy link

renaudboulard commented Dec 13, 2024

The solution is to manually call the google account creation when we have this exceptions

 if (error is NoCredentialException) {
    launchAddGoogleAccount()
}
  private fun launchAddGoogleAccount() {
    val intent = Intent(Settings.ACTION_ADD_ACCOUNT)
    intent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, arrayOf("com.google"))
    addAccountLauncher.launch(intent);
  }
  
  private val addAccountLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult ->
    if (result.resultCode == RESULT_OK) {
      authChoicesViewModel.onGoogleButtonClick()
    } else {
      viewModel.hideProgress()
    }
  }

Unfortunately, RESULT_OK is never triggered. Even if we successfully add a Google account, the app returns with RESULT_CANCELED. As a result, the user will need to click on 'Login with Google' in our app again after adding a Google account.

@kimchanghyun
Copy link

Is this a problem that hasn't been solved yet?
I don't know how many days I've been struggling with this.

@Azbesciak
Copy link

Azbesciak commented Jan 10, 2025

I am getting the following error regarding the same

During begin sign in, failure response from one tap: 16: [28439] User disabled the feature.

Any idea why it does not work? For normal GoogleSignIn it is working.
As I checked https://www.reddit.com/r/UpNote_App/comments/1328umg/error_16_while_trying_to_sign_up_using_google/?rdt=64332 I have my app in settings.

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

9 participants