トークンを取り消すには、Google サンプル アプリのこの関数を使用します。
function revokeToken() {
user_info_div.innerHTML="";
chrome.identity.getAuthToken({ 'interactive': false },
function(current_token) {
if (!chrome.runtime.lastError) {
// @corecode_begin removeAndRevokeAuthToken
// @corecode_begin removeCachedAuthToken
// Remove the local cached token
chrome.identity.removeCachedAuthToken({ token: current_token },
function() {});
// @corecode_end removeCachedAuthToken
// Make a request to revoke token in the server
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://accounts.google.com/o/oauth2/revoke?token=' +
current_token);
xhr.send();
// @corecode_end removeAndRevokeAuthToken
// Update the user interface accordingly
changeState(STATE_START);
sampleSupport.log('Token revoked and removed from cache. '+
'Check chrome://identity-internals to confirm.');
}
});
}