Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google SignIn error getToken() -> NEED_REMOTE_CONSENT

Few month ego, my google signIn procedure works without problem, but today the emulator reply me in the Logcat this error:

E/Auth: [GoogleAccountDataServiceImpl] getToken() -> NEED_REMOTE_CONSENT. App: com_pro.bandweb.mycpstore, Service: oauth2:email https://www.googleapis.com/auth/spreadsheets.readonly openid profile

try to look in google but I not find any suggestion...this are the code that I use for sigIn:

public void InitGoogle() throws IOException {
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(SPREADSHEETS_SCOPE))
                .requestEmail()
                .build();
        googleSignInClient = com.google.android.gms.auth.api.signin.GoogleSignIn.getClient(this, gso);

        if (GoogleSignIn.getLastSignedInAccount(this) == null) {
            Log.v(TAG, "getting sign-on again");
            //startActivityForResult(googleSignInClient.getSignInIntent(), RC_SIGN_IN);
            SignInActivityResult.launch(googleSignInClient.getSignInIntent());
        } else {
            Log.v(TAG, "sign-on is still good, reusing");

            //faccio la richiesta solo se è stato inserito il foglio di google shhet nelle preferenze, altrimenti avviso
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
            if (!sharedPreferences.contains(getString(R.string.pref_googleSheetId_key))
                    || StringUtils.isBlank(sharedPreferences.getString(getString(R.string.pref_googleSheetId_key), ""))
                    || !(spreadsheetIdPattern.matcher(sharedPreferences.getString(getString(R.string.pref_googleSheetId_key), ""))).find()) {
                // no Google sheet ID has been specified - can't retrieve ingredients
                progressBar.setVisibility(ProgressBar.GONE);
                Toasty.info(this, getString(R.string.missing_pref_id_sheet_title), Toasty.LENGTH_LONG, true).show();
            }else {
                //scelgo il tipo di sincronizzazione quando inizializzo il tablet, in base alla scelta nelle preferenze
                if(AppSettings.get().getSyncModeOnStartup() == UPLOAD_DATI)
                    synchGoogleSheet(UPLOAD_DATI);
                else if(AppSettings.get().getSyncModeOnStartup() == DOWNLOAD_DATI)
                    synchGoogleSheet(DOWNLOAD_DATI);
                else
                    synchGoogleSheet(UPLOAD_DOWNLOAD_NONE);
            }
        }
        progressBar.setVisibility(ProgressBar.GONE);

..
..
..
..





ActivityResultLauncher<Intent> SignInActivityResult= registerForActivityResult(
        new ActivityResultContracts.StartActivityForResult(),
        new ActivityResultCallback<ActivityResult>() {
            @Override
            public void onActivityResult(ActivityResult result) {
                if(result.getResultCode() != RESULT_CANCELED) {
                    if (result.getResultCode() == Activity.RESULT_OK && null != result.getData())
                    {
                        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(result.getData());
                        handleSignInResult(task);
                    }
                }else{
                    progressBar.setVisibility(ProgressBar.GONE);
                }
            }
        });
like image 326
Andy Band Avatar asked Jul 20 '21 10:07

Andy Band


1 Answers

I had the same issue on a Google Pixel 5 with Android 11.

2021-08-11 13:32:59.603 29917-30363/? E/Auth: [GoogleAccountDataServiceImpl] getToken() -> NEED_REMOTE_CONSENT. App: de.aoksystems.ma.abp.app.internal, Service: oauth2:https://www.googleapis.com/auth/fitness.activity.read https://www.googleapis.com/auth/fitness.heart_rate.read https://www.googleapis.com/auth/fitness.nutrition.read

But it works fine on a Samsung S10 with Android 11

4 Weeks ago it works.

like image 100
SebLu Avatar answered Oct 20 '22 01:10

SebLu