Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCP Api com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException

Im trying to upload image on google drive. The API seems is verified. Since in GCP console I got

Verification Status Verified Your consent screen has been verified. If you make changes that require verification later, you must resubmit your application for review

But after uploading i have exception

com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException

And cause

com.google.android.gms.auth.UserRecoverableAuthException: NeedRemoteConsent

Full exception message enter image description here

like image 984
Boris Ruzanov Avatar asked Nov 06 '22 00:11

Boris Ruzanov


1 Answers

Also faced the same error. When calling a Drive service, you should catch UserRecoverableAuthIOException, get the intent from it UserRecoverableAuthIOException#getIntent() and start the intent with startActivityForResult to show an OAuth2 permission page to user. Then handle a user's choice in onActivityResult.

try {
    // Some call to the Drive
} catch (UserRecoverableAuthIOException e) {
    startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
}

You can test it by revoking a permission for your app in your Google Drive settings.

like image 183
VasyaV Avatar answered Nov 15 '22 08:11

VasyaV