3

I'm trying to add sign in with google button to my application. I followed the google documentation. But always the result is given for me is null. Therefore I cannot access result.isSuccess(). It gives com.google.android.gms.auth.UserRecoverableAuthException: BadAuthentication exception. I followed all the steps correctly.

This is the sign in intent.

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent, 1);

This is where I receive result

if (requestCode == 1) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        handleSignInResult(result);
    }

handleSignInResult() method

private void handleSignInResult(GoogleSignInResult result) {
    Log.e("Result",result.getStatus().toString());
    if (result.isSuccess()) {
        GoogleSignInAccount acct = result.getSignInAccount();
        String idToken = acct.getIdToken();
        gtoken();
    } else {
        Toast.makeText(LoginListener.this,"Unsuccessful",Toast.LENGTH_SHORT).show();
    }
}

google sign in option

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

I cannot find what is the reason. If you need to know anything please comment. Any help is highly appreciated. Thank you.

Choxmi
  • 1,584
  • 4
  • 29
  • 47

1 Answers1

0

I don't know what you invoked so that you got UserRecoverableAuthException back.

But if you got result.getStatus().getStatusCode() == 8 (INTERNAL_ERROR), then you probably are missing a dev console registration.

Occured an INTERNAL_ERROR when requestEmail from GoogleSignInOptions Android

Community
  • 1
  • 1
Isabella Chen
  • 2,421
  • 13
  • 25
  • Thank you for your answer. I downloaded android studio again and I changed my sha1 to the keystore file of my newly downloaded android studio's keystore file. It worked. – Choxmi Jan 29 '16 at 07:16