gpt4 book ai didi

android - 在 Android 上使用 GoogleSignInClient 静默签名时出现 ApiException

转载 作者:行者123 更新时间:2023-11-29 19:01:31 25 4
gpt4 key购买 nike

当我尝试在 Android 上静默登录时,我经常遇到以下错误。我该如何调试。这是什么原因。 (我的 Android 手机上有一个有效的 Google 帐户。)

signInSilently(): failure
com.google.android.gms.common.api.ApiException: 4:
at com.google.android.gms.common.internal.zzb.zzz(Unknown Source)
at com.google.android.gms.common.internal.zzbk.zzaa(Unknown Source)
at com.google.android.gms.common.internal.zzbl.zzs(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.zzc(Unknown Source)
at com.google.android.gms.common.api.internal.zzs.setResult(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzg.zza(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzt.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:446)

代码如下

 mGoogleSignInClient.silentSignIn().addOnCompleteListener(activity,
new OnCompleteListener<GoogleSignInAccount>() {
@Override
public void onComplete(@NonNull Task<GoogleSignInAccount> task) {
if (task.isSuccessful()) {
Log.d(TAG, "signInSilently(): success");
onConnected(task.getResult());
} else {
Log.d(TAG, "signInSilently(): failure", task.getException());
Toast.makeText(activity, "A sign-in problem encountered.",
Toast.LENGTH_SHORT).show();
onDisconnected();
}
}
});

最佳答案

a list of error codes

据此,您的错误代码表示如下:

public static final int SIGN_IN_REQUIRED
The client attempted to connect to the service but the user is not signed in. The client may choose to continue without using the API. Alternately, if hasResolution() returns true the client may call startResolutionForResult(Activity, int) to prompt the user to sign in. After the sign in activity returns with RESULT_OK further attempts should succeed.

Constant Value: 4

这意味着,用户需要手动登录才能使用silentSignIn。你可以找到一个例子 on Google github

关于android - 在 Android 上使用 GoogleSignInClient 静默签名时出现 ApiException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48923966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com