问题
I have a Chrome browser extension that requests access using chrome.identity.getAuthToken, and is working as expected. In the extension you can logout using:
var do_logout = function() {
chrome.identity.getAuthToken({'interactive': false}, function(token) {
chrome.identity.removeCachedAuthToken({token:token}, function(){
display_login();
});
});
};
Which again is working fine. The issue is when you log back in. Ideally I want the extension to ask for permission again - mainly for testing from different accounts - but even when I request a login with interactive=true I don't get the interactive UI, like this:
chrome.identity.getAuthToken({'interactive': true }, function(token) {
I can login to my Google Accounts page and revoke access from there, but it's a bit of a faff, and it feels cleaner that if I want to signout from something that I would have to grant permission again to sign back in.
Is there a way of an extension revoking it's own access to a users account? I would presume so, but I am hitting a wall on Google. The best I found is this "Revoking a token", but it feels like there should be a way to do it with chrome.identity or chrome.permissions.
回答1:
As I know, the chrome identity is controlled by the Google account signed into the Chrome browser, not the web session for Google. Chrome app identities are tied to the Google account signed into Chrome. You can change the current signed in account in Chrome settings, but I recommend you create a new Chrome profile instead.
来源:https://stackoverflow.com/questions/27784461/how-to-revoke-google-account-access-from-within-an-extension