在 Android 上使用 GoogleSignInClient 进行静默签名时的 ApiException [英] ApiException on silent signing using GoogleSignInClient on Android

查看:15
本文介绍了在 Android 上使用 GoogleSignInClient 进行静默签名时的 ApiException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I get following error frequently when I try to sign in silently on android. How can I debug this. What is the reason for this. (I have an active google account on my android phone.)

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();
             }
          }
       });

推荐答案

错误代码列表

根据它,您的错误代码含义如下:

According to it, your error code means following:

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.您可以找到一个示例 在 Google github 上

It means, that user needs to login manually before you can use silentSignIn. You can find an example on Google github

这篇关于在 Android 上使用 GoogleSignInClient 进行静默签名时的 ApiException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆