通过Google Play服务撤消驱动器访问权限 [英] Revoke drive access through Google Play Services
问题描述
是否可以撤消通过Google Play服务授予的驱动器访问权限?
Is there a way to revoke drive access granted through Google Play Services?
引用本文: https://developer.android.com/google/auth/api-client.html
我授予了从我的应用访问g驱动器的权限,如下所示:
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();
我的问题是,是否有清除G驱动器访问权限的干净方法
My question is, is there a clean way to revoke g drive access
即无需执行credential.getToken()并进行http调用 https://accounts.google.com/o/oauth2/revoke?token=
i.e. without needing to do credential.getToken() and making http call to https://accounts.google.com/o/oauth2/revoke?token=
我正在寻找类似Drive.DriveApi.revokeAccessAndDisconnect();
I'm looking for something like Drive.DriveApi.revokeAccessAndDisconnect();
我知道g可以加一个,但是我找不到g可以加一个. http://developer.android.com/reference/com/google/android/gms/plus/Account.html
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
推荐答案
是的,有一种方法可以撤消Google云端硬盘范围.
Yes, there is an method for revoking of Google Drive scope.
GoogleSignInClient googleSignInClient = buildGoogleSignInClient();
googleSignInClient.revokeAccess().addOnCompleteListener(onCompleteListener);
其中
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
这篇关于通过Google Play服务撤消驱动器访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!