Google Play Games Services Signin Problems

Viewed 624

I've been banging my head on my desk the past few days trying to figure out how to setup the sign-in for Google Play Games Services.

I am able to start an activity for an interactive signin, but the window just hangs and loads forever with no error:

enter image description here

Here is the code I have. It checks to see if the user has signed in before, if they have, it attempts to login silently. If not, it brings up interactive signin:

final GoogleSignInOptions signInOption =
    new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
    // Add the APPFOLDER scope for Snapshot support.
    .requestScopes(Games.SCOPE_GAMES_SNAPSHOTS)
    .requestIdToken(activity.getString(R.string.debug_client_id))
    .requestEmail()
    .build();

signInClient = GoogleSignIn.getClient(this, signInOption);

GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
if (account != null) {
    // The user has signed in before

    signInClient.silentSignIn().addOnCompleteListener(new OnCompleteListener < GoogleSignInAccount > () {
        @Override
        public void onComplete(@NonNull Task < GoogleSignInAccount > task) {
            if (task.isSuccessful()) {
                // Silent signin successful
                onConnected(task.getResult());
            } else {
                // Player will need to sign-in explicitly using via UI    
                // Interactive sign-in
                activity.startActivityForResult(signInClient.getSignInIntent(), AndroidLauncher.RC_SIGN_IN);
            }
        }
    });

} else {
    //The user has never signed in
    // Interactive sign-in
    this.activity.startActivityForResult(signInClient.getSignInIntent(), AndroidLauncher.RC_SIGN_IN);
}

I also have the onActivityResult() handler:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            signedIn = true;
            // The signed in account is stored in the result.
            GoogleSignInAccount signedInAccount = result.getSignInAccount();
        } else {
            signedIn = false;
            String message = result.getStatus().getStatusMessage();
            if (message == null || message.isEmpty()) {
                message = "Sign in error!";
            }
            new AlertDialog.Builder(this).setMessage(message)
                    .setNeutralButton(android.R.string.ok, null).show();
        }
    }
}

What I've Tried/Done

  • I added the required metadata tags in the AndroidManifest.xml file (with correct values)

  • I've added the Google Play Games account as a tester on the Google Play Console for the app, for Google Play Services, and on the OAuth consent screen for the API on Google Cloud Platform.

  • I've checked that the SHA-1 hash of the signature on the app matches the SHA-1 hash of the OAuth credential in use on Google Play Games, and that the client ID is correct and is of the selected OAuth credential.

  • I have enabled all of the non-sensitive data scopes (which is all I need) on the Google Cloud Platform OAuth consent screen

More Info

If I try to call signInSilently(...) before the interactive signin, I get API exception code 4 (SIGN_IN_REQUIRED). When I execute the interactive signin, it just hangs like above. I actually am able to get the signin to work, but only if I use signin options like so:

final GoogleSignInOptions signInOption = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build();

(with no snapshots permissions and no passed client ID. But I need to be able to access snapshots)

The only possibly relevant exception I see in Logcat when running the interactive signin is:

E/ExecutionCriteria: Package unavailable for task: com.google.android.apps.tachyon/com.firebase.jobdispatcher.GooglePlayReceiver{u=0 tag="duo-analytics-summary-report" trigger=window{start=82080s,end=86401s,earliest=-97027894s,latest=-97023574s} requirements=[NET_ANY] attributes=[PERSISTED,RECURRING] scheduled=-97109975s last_run=N/A exec_window_multiplier=1.0000 jid=N/A status=PENDING retries=0 client_lib=FIREBASE_JOB_DISPATCHER-1} [CONTEXT service_id=218 ]

...but it seems like it might be a benign error.

I've been stuck on this for a while; any suggestions/help would be appreciated.

0 Answers
Related