问题
Is there a way to revoke drive access granted through Google Play Services?
Referring to this article: https://developer.android.com/google/auth/api-client.html
I granted access to g drive from my app like so:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
My question is, is there a clean way to revoke g drive access
i.e. without needing to do credential.getToken() and making http call to https://accounts.google.com/o/oauth2/revoke?token=
I'm looking for something like Drive.DriveApi.revokeAccessAndDisconnect();
I know there is one for g plus, but i cant find one for g drive. http://developer.android.com/reference/com/google/android/gms/plus/Account.html
回答1:
Yes, there is an method for revoking of Google Drive scope.
GoogleSignInClient googleSignInClient = buildGoogleSignInClient();
googleSignInClient.revokeAccess().addOnCompleteListener(onCompleteListener);
where
private GoogleSignInClient buildGoogleSignInClient() {
GoogleSignInOptions signInOptions =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(Drive.SCOPE_FILE)
.build();
return GoogleSignIn.getClient(this, signInOptions);
}
For more information, you can check this reference
来源:https://stackoverflow.com/questions/24558356/revoke-drive-access-through-google-play-services