googlesamples / google-services

A collection of quickstart samples demonstrating the Google APIs for Android and iOS
https://developers.google.com
Apache License 2.0
3.07k stars 2.53k forks source link

E/Auth: [GoogleAccountDataServiceImpl] getToken() -> NEED_REMOTE_CONSENT. App: _packagename_, Service: oauth2:email https://mail.google.com/ openid profile #516

Open spiraldevapps opened 3 years ago

spiraldevapps commented 3 years ago

Step 1: Are you in the right place?

This is a bug - everything was working fine and then since last 4 weeks we are facing this issue.

Step 2: Describe your environment

Step 3: Describe the problem:

Steps to reproduce:

  1. Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(gApiClient);
  2. startActivityForResult(signInIntent, REQUEST_ACCOUNT_PICKER);

Observed Results:

Expected Results:

Relevant Code:

   GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                            .requestIdToken(Constant.serverclientid) // required to get accesstoken
                            .requestScopes(new Scope(GmailScopes.MAIL_GOOGLE_COM))
                            .requestEmail()
                            .build();

                    GoogleApiClient gApiClient = new GoogleApiClient.Builder(getApplicationContext())
                            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                            .build();

                    ConnectionResult c = gApiClient.blockingConnect();

                    if (c.isSuccess() && gApiClient.isConnected()) {
                        Log.e(TAG,"connectionResult = success");
                        gApiClient.clearDefaultAccountAndReconnect().await();
                    }
                    else
                    {
                        Log.e(TAG,"connectionResult is failure");
                    }

                    GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(getApplicationContext(), gso);
                    mGoogleSignInClient.revokeAccess();

                  //  Intent signInIntent = mGoogleSignInClient.getSignInIntent();

                    Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(gApiClient);

                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {

                            Log.d(TAG,"request account picker");

                            Aloading_spinner.setVisibility( View.GONE );
                            startActivityForResult(signInIntent, REQUEST_ACCOUNT_PICKER);

                        }
                    });
glebkravchenko commented 3 years ago

Having same problem, do we have any solution?

entrealist commented 2 years ago

Also experiencing this issue. Does this happen due to requests cooldown during a series of consecutive closures? Maybe 2FA?