GoogleドライブWebアプリケーションに付与されているアクセスを取り消して、ユーザーが次に使用するときにアクセス許可を新たに要求されるようにするにはどうすればよいですか。
5 に答える
アクセストークンを取り消すには、次のURLを「GET」(!)する必要があります 。https ://accounts.google.com/o/oauth2/revoke? token = {token}ここで、{token}はトークンの値です。ここで説明されているように: https ://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke
Java API(他の言語については不明)の場合、2012年9月9日の時点で、このためのAPIはありません。私はこのコードでトークンを取り消すことができました:
class myGoogleApi {
private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
...
public revoke(String token) {
HttpRequestFactory factory = HTTP_TRANSPORT.createRequestFactory();
GoogleUrl url = new GoogleUrl("https://accounts.google.com/o/oauth2/revoke?token="+token);
HttpRequest request = factory.buildGetRequest(url);
HttpResponse response = request.execute();
...
}
DB内のすべての更新トークンを壊した場合は、クエリパラメータapproval_prompt=forceを認証リクエストに追加すると修正されます。これにより、ユーザーが次にリクエストを承認したときに更新トークンが再発行されます。
アクセスを取り消すには、以下のURLにアクセスしてください
https://security.google.com/settings/security/permissions?pli=1
取り消す必要のあるアプリを選択し、[削除]をクリックします。
アクセスを許可したアプリケーションとサイトのリストについては、https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=enにアクセスしてください。それぞれの横に、[アクセスを取り消す]ボタンがあります。
そのページにアクセスする手順は、http://support.google.com/accounts/bin/answer.py?hl = en&answer=41236にあります。
Google Playサービスの使用:
http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html
https://www.googleapis.com/auth/userinfo.profileをスコープに追加します。
例:
String scope="oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
final String token = GoogleAuthUtil.getToken(context, "xxxx@gmail.com", scope);
または「ブルートフォース」
Intent res = new Intent();
res.addCategory("account:xxxx@gmail.com");
res.addCategory("scope:oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
res.putExtra("service", "oauth2:https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile");
Bundle extra= new Bundle();
extra.putString("androidPackageName","com.your.package");
res.putExtra("callerExtras",extra);
res.putExtra("androidPackageName","com.your.package");
res.putExtra("authAccount","xxxx@gmail.com");
String mPackage = "com.google.android.gms";
String mClass = "com.google.android.gms.auth.TokenActivity";
res.setComponent(new ComponentName(mPackage,mClass));
startActivityForResult(res,100);
ここでhttps://accounts.google.com/IssuedAuthSubTokensへのアクセスを取り消すと、アプリケーションはデバイスでの許可のウィンドウを再度表示します。