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

查看:76
本文介绍了在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.您可以找到

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天全站免登陆