Removing extension permissions

I have an extension that first requests permissions to access Google Drive files. The extension is almost empty except for a popup. I load this js:

chrome.identity.getAuthToken({ 'interactive': true }, function(token) { // Use the token. console.log('Request Token') console.log(token) chrome.identity.removeCachedAuthToken( { 'token': token }, function () {}) console.log('Removed token') }); 

In my manifest, I have a valid key, oauth2 client id and "scopes":["https://www.googleapis.com/auth/drive"] among other standard keys for chrome extension.

It works correctly, so permission is first requested, and then my access token is registered. However, when I reinstalled the extension (deleted / modified / added), he did not ask for permission and simply wrote the same access token. And I want to ask permission again. How can i do this?

+5
javascript google-chrome-extension google-drive-sdk access-token
source share
3 answers

To remove permissions, I have to add another GET request to revoke the permission:

 chrome.identity.getAuthToken({ 'interactive': true }, function(token) { // Use the token. if (token) { // Make a request to revoke token var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://accounts.google.com/o/oauth2/revoke?token=' + token); xhr.send(); } chrome.identity.removeCachedAuthToken( { 'token': token }, function () {}) }); 

This does the trick, and now every time I open a popup, I get a permission request.

There is another problem: when I grant permission, I get

 XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/revoke?token=... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://acfnd...' is therefore not allowed access. 

which I'm not sure what it means.

+6
source share

During development, you can go to chrome://identity-internals to revoke specific tokens. The next time you authorize this user, the rights dialog will be displayed again. Documented for User Authentication: Caching .

+6
source share

Once you grant permission, of course, you will not be asked again. You will need to go to your Google Account page and revoke this permission.

0
source share

All Articles