Menu

1 / 5

OAuth 2.0 in Chrome Extensions: Setup, Tokens, Pitfalls

DEV Community: javascript·ExtensionBooster·8 days ago
#Tau1oLQZ
#devtojavascript#devto#dev#token#chrome
Long article (883 words) — no AI summary yet.
Reading 0:00
15s threshold

Originally published on ExtensionBooster .

Adding OAuth 2.0 to a Chrome extension trips up a lot of developers because the usual web redirect flow simply does not fit. This walkthrough covers the four setup steps, a small token helper you can drop into a Manifest V3 project, and the mistakes that cause most "it worked yesterday" auth bugs.

Why extensions can't use the normal redirect flow

A typical web app sends the user to Google, then Google redirects back to an HTTPS callback URL. Extension pages are not served over HTTPS, so that pattern breaks.

Chrome solves this with the Identity API ( chrome.identity ). It handles:

the Google consent screen

token caching between sessions

silent sign-in for users who already granted access

redirects, so you configure no redirect URI at all

Your extension never sees a password. It asks Chrome for an access token and sends that token to Google APIs such as Gmail, Drive, Calendar or Contacts.

The four setup steps

Lock your extension ID.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.