Revoke drive access through Google Play Services

做~自己de王妃 提交于 2021-01-28 01:42:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!