Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

google api - ApiException on silent signing using GoogleSignInClient on Android

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)

the code is follows

 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();
             }
          }
       });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is a list of error codes

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...