Skip to content
AnswerWell geo Documentation

Research · 6 min read · Answerwell

Extension Identity API, FCM Registration, and Instance ID

How Chrome extension APIs obtain OAuth tokens, register with FCM, and manage Instance ID tokens for push and backend access.

This page summarizes Chrome extension API reference documentation for obtaining OAuth2 tokens, registering with Firebase Cloud Messaging (FCM), and using the Instance ID service. The cluster centers on three related surfaces: browser.identity / chrome.identity, browser.gcm / chrome.gcm, and browser.instanceID / chrome.instanceID. Together they cover how an extension identifies the user to Google APIs, registers for cloud messaging, and holds stable instance-scoped tokens.

chrome.identity and OAuth2: how extensions get auth tokens

Section titled “chrome.identity and OAuth2: how extensions get auth tokens”

Extensions that call Google APIs on the user’s behalf use the Identity API to request OAuth2 scopes and retrieve tokens, often via getAuthToken (parameters documented under the same reference pages).

When you fetch a token, you can steer account and scope behavior:

If not specified, the function will use an account from the Chrome profile: the Sync account if there is one, or otherwise the first Google web account.

— Chrome, chrome.identity

When the scopes field is present, it overrides the list of scopes specified in manifest.json.

— Chrome, chrome.identity

Successful requests can expose grantedScopes (a list of OAuth2 scopes granted to the extension) and an optional token string associated with the request—see browser.identity properties.

interactive flag: when getAuthToken prompts the user

Section titled “interactive flag: when getAuthToken prompts the user”

Fetching a token may require the user to sign-in to Chrome, or approve the application’s requested scopes. If the interactive flag is true, getAuthToken will prompt the user as necessary. When the flag is false or omitted, getAuthToken will return failure any time a prompt would be required.

— Chrome, browser.identity

Use interactive: true when a background flow must recover from missing consent or sign-in. Use non-interactive mode only when you accept hard failure if a prompt would be needed—for example, silent refresh paths that should not pop UI.

The enableGranularPermissions flag allows extensions to opt-in early to the granular permissions consent screen, in which requested permissions are granted or denied individually.

— Chrome, browser.identity

On browser.identity, this flag is noted as available on Chrome 87+ with browser.* since Chrome 148.

To remove a specific cached token, pass token—the string that should be removed from the cache—using the API surface documented in browser.identity and chrome.identity.

chrome.gcm.register: FCM registration ID for extensions

Section titled “chrome.gcm.register: FCM registration ID for extensions”

GCM/FCM registration is separate from OAuth: it yields a registration ID your backend uses to target this extension install for push-related messaging.

Registers the application with FCM. The registration ID will be returned by the callback. If register is called again with the same list of senderIds, the same registration ID will be returned.

— Chrome, browser.gcm

The Manifest V2 reference documents the same contract as a Promise:

chrome.gcm.register(senderIds: string[], callback?: function,): Promise<string>

— Chrome, chrome.gcm

Call unregister() when the extension should disconnect from FCM entirely (Promise<void> on browser.gcm).

chrome.instanceID: app instance identifier and scoped tokens

Section titled “chrome.instanceID: app instance identifier and scoped tokens”

Instance ID gives a stable per-install identifier and tokens scoped to an authorized entity and action scope—commonly used alongside messaging.

Use chrome.instanceID to access the Instance ID service.

— Chrome, chrome.instanceID

getID and deleteID: instance identity lifecycle

Section titled “getID and deleteID: instance identity lifecycle”

Retrieves an identifier for the app instance. The instance ID will be returned by the callback. The same ID will be returned as long as the application identity has not been revoked or expired.

— Chrome, browser.instanceID

Resets the app instance identifier and revokes all tokens associated with it.

— Chrome, browser.instanceID

After deleteID(), expect a new ID on the next getID() once identity is re-established.

Return a token that allows the authorized entity to access the service defined by scope.

— Chrome, browser.instanceID

Parameters:

Parameter Role
authorizedEntity Entity allowed to access resources for this Instance ID; can be a project ID from Google developer console (Chrome 46+).
scope Authorized actions—e.g. for sending GCM messages, GCM scope should be used (Chrome 46+).

Identifies authorized actions that the authorized entity can take. E.g. for sending GCM messages, GCM scope should be used.

— Chrome, browser.instanceID

Revoke one granted token with deleteToken(deleteTokenParams) where authorizedEntity and scope match how the token was obtained (browser.instanceID).

options are deprecated and will be ignored.

— Chrome, browser.instanceID

Do not rely on options in getTokenParams; they are deprecated since Chrome 89.

chrome.instanceID.getCreationTime (MV2 reference only in this cluster) returns when the Instance ID was generated as a Promise resolving to a number. The browser.instanceID excerpt in this cluster does not list that method—check the full reference for your target manifest version.

How Identity, GCM, and Instance ID fit together

Section titled “How Identity, GCM, and Instance ID fit together”
Concern API Typical output
User-backed Google API access chrome.identity / browser.identity OAuth2 token, grantedScopes
FCM endpoint for this install chrome.gcm.register Registration ID (stable for same senderIds)
Instance + messaging-scoped token chrome.instanceID Instance ID string; scoped token via getToken

OAuth tokens authenticate users to Google APIs. FCM registration IDs address delivery to this extension instance via FCM. Instance ID ties a device/install identity to scoped tokens (including GCM-related scope). Pick the API that matches what your backend expects; mixing registration ID with Instance ID token without matching server logic is a common integration mistake.

browser.* vs chrome.* in this documentation

Section titled “browser.* vs chrome.* in this documentation”

Modern reference pages use the browser.* namespace (e.g. browser.gcm.register) with Promises. Manifest V2 references document chrome.* with optional callbacks plus Promises—for example chrome.gcm.register(senderIds, callback?). Behavior descriptions (FCM register/unregister, Instance ID lifecycle, identity flags) align across pairs; choose the namespace that matches your extension manifest and minimum Chrome version (browser.* since Chrome 148 on several identity fields).

  • Calling getAuthToken without interactive: true when the user has not yet approved scopes—calls fail instead of showing consent (browser.identity).
  • Passing scopes at runtime while assuming manifest.json scopes still apply—they are overridden when scopes is present.
  • Using Instance ID getToken without the correct scope for GCM messaging when the backend expects GCM-scoped tokens.
  • Depending on deprecated options in getTokenParams—ignored since Chrome 89.
  • Calling deleteID() without updating your server’s stored instance mapping—old tokens are revoked but clients may still reference stale IDs.
  1. Confirm your extension manifest declares the permissions required for Identity, GCM, and/or Instance ID as described in the full Chrome extension docs for your manifest version.

  2. In a test profile, call getAuthToken with interactive: true once and verify grantedScopes includes the scopes you pass or configure in the manifest.

  3. Call browser.gcm.register or chrome.gcm.register with your production senderIds and confirm a stable registration ID across two register calls with the same array.

  4. Exercise getID, then getToken with your project ID as authorizedEntity and the GCM-related scope your server expects; after deleteToken or deleteID, confirm tokens and IDs change as documented.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the official references or your extension behavior, email yimasynthetic@gmail.com with the page URL and the exact statement you want clarified or corrected.