Switching google account with drive access

Skip to first unread message

Tanzim mahtab

Jun 12, 2024, 5:44:47 AMJun 12
to Chromium Extensions
Hey folks, 
Here is my current code to access the Google Drive files in the popup ( it works )  :
// manifest.json
  "oauth2": {
    "client_id": "xyz.apps.googleusercontent.com",
    "scopes": [

// popup.js 
chrome.identity.getAuthToken({ interactive: true }, function (token) {})

I added a button to switch accounts and used this same method to pick a Google account when the button is clicked:
chrome.identity.getAuthToken({ interactive: true }, function (token) {})

But, as I am already logged in,  it does not work ( the Google account picker does not pop up and the token in the callback is the previously logged-in token ). 

Is there any way to switch accounts with Google Drive access?
I really appreciate any help you can provide. 

Patrick Kettner

Jun 27, 2024, 5:49:51 AMJun 27
to Tanzim mahtab, Chromium Extensions
Hi Tanzim!
You need to clear the existing token by calling chrome.identity.clearAllCachedAuthTokens. Once it is removed, you can call getAuthToken again to go through the original flow.

You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/109a6e77-5116-4f2d-9426-845ea9c8a77bn%40chromium.org.
Reply all
Reply to author
0 new messages