我正在为gmail制作Chrome扩展程序,当我第一次运行此代码段时,一切正常,对话框显示并询问用户使用哪个帐户并存储令牌,我可以使用我的扩展程序中的gmail API:
var access_token = "";
chrome.identity.getAuthToken({ 'interactive': true },
function(token) {
if (!!token) {
access_token = token;
gapi.auth.setToken({ access_token: token });
}
}
);
但是当我用这段代码删除令牌时:
chrome.identity.removeCachedAuthToken({ token: access_token }, function() {
console.log('token removed');
});
我希望使用第一个代码段再次获取令牌,它会更新令牌本身,而不向用户显示对话框以选择要使用的帐户。 如何强制它显示对话框?
答案 0 :(得分:1)
如评论中所述,您需要revoke the token才能完全删除存储的凭据。
curl -H "Content-type:application/x-www-form-urlencoded" \
https://accounts.google.com/o/oauth2/revoke?token={token}