I'm trying to develop a chrome extension using Google Accounts as the identity. I'm following the tutorial at http://developer.chrome.com/extensions/app_identity.html
I made sure the client_id and the extension id are associated. However, I'm not sure when to call chrome.extension.getAuthToken()
I call it at onInstalled event (on my extension background page) but get an "undefined" token back without any error. (Likewise calling it from the background page console yields the same result)
Since getAuthToken()
may require a UI (when interactive is set to true), I'm guessing perhaps it cannot be called from a background page. If so, when and where should chrome.identity.getAuthToken()
be called from an extension?
The tokens are stored securely by the user's browser, and can then be redeemed in other contexts to confirm the user's authenticity.
Turns out you can call getAuthToken() from the background page. The authorization UI shown is a dialog box, not a regular html page, so I guess that's allowed from the background page.
FWIW, my problem was not giving a "Product name", since I was using an old google api test account. You need to give a name under "Consent screen" in the 'new' cloud developers console, or under "Edit Branding Info" in the old console.
You get a cryptic "bad client_id {0}" error otherwise!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With