identity API

Hint

The identity API is inherited from Firefox, and its primary documentation is maintained by Mozilla at MDN. Thunderbird implements only the subset of functions, events, and types listed here. The MDN pages may provide further details and examples, but they may also reference features that are not supported in Thunderbird.

Use the chrome.identity API to get OAuth2 access tokens.

Permissions

The following permissions influence the behavior of the API. Depending on which permissions are requested, additional methods might be available, or certain data may be included in responses.

Hint

Request permissions only when needed. Unnecessary requests may result in rejection during ATN review.

identity

identity

Grant access to some or all methods of the identity API.

Note

The permission identity is required to use messenger.identity.*.

Functions

getAccounts()

Retrieves a list of AccountInfo objects describing the accounts present on the profile.

Return type (Promise)

_returns

array of AccountInfo

Required permissions

  • identity

getAuthToken([details])

Gets an OAuth2 access token using the client ID and scopes specified in the oauth2 section of manifest.json.

Parameters

details

[details]

(object, optional)

account

[account]

(AccountInfo, optional)

interactive

[interactive]

(boolean, optional)

scopes

[scopes]

(array of string, optional)

Return type (Promise)

_returns

array of AccountInfo

Required permissions

  • identity

getProfileUserInfo()

Retrieves email address and obfuscated gaia id of the user signed into a profile.

Return type (Promise)

_returns

object

email

email

(string)

id

id

(string)

Required permissions

  • identity

getRedirectURL([path])

– [Added in TB 53]

Generates a redirect URL to be used in launchWebAuthFlow(details).

Parameters

path

[path]

(string, optional)

The path appended to the end of the generated URL.

Return type (Promise)

_returns

string

Required permissions

  • identity

launchWebAuthFlow(details)

– [Added in TB 53]

Starts an auth flow at the specified URL.

Parameters

details

details

(object)

url

url

interactive

[interactive]

(boolean, optional)

Return type (Promise)

_returns

string

Required permissions

  • identity

removeCachedAuthToken(details)

Removes an OAuth2 access token from the Identity API’s token cache.

Parameters

details

details

(object)

token

token

(string)

Return type (Promise)

_returns

object

email

email

(string)

id

id

(string)

Required permissions

  • identity

Events

onSignInChanged

Fired when signin state changes for an account on the user’s profile.

Parameters for onSignInChanged.addListener(listener)

listener(account, signedIn)

listener(account, signedIn)

A function that will be called when this event occurs.

Parameters passed to the listener function

account

account

signedIn

signedIn

(boolean)

Required permissions

  • identity

Types

AccountInfo

An object encapsulating an OAuth account id.

object

id

id

(string)

A unique identifier for the account. This ID will not change for the lifetime of the account.

HttpURL

string