getAccessToken

open override fun getAccessToken(scope: String, useCache: Boolean): AccessTokenInfo

Get a short-lived OAuth access token for the user's account.

💾 This method alters the persisted account state.

Applications that need to access resources on behalf of the user must obtain an access_token in order to do so. For example, an access token is required when fetching the user's profile data, or when accessing their data stored in Firefox Sync.

This method will obtain and return an access token bearing the requested scopes, either from a local cache of previously-issued tokens, or by creating a new one from the server.

Arguments

- `scope` - space-separated list of OAuth scopes to be granted by the token.
    - Each scope must have been requested during the signin flow, or be a scope
      which the server might offer automatically in some account-specific cases.
    - Scope order is not significant; `"a b"` and `"b a"` are equivalent.
    - When a single scope is requested and it has an associated scoped key
      (e.g. `https://identity.mozilla.com/apps/oldsync`), the returned
      `AccessTokenInfo.key` will be populated; for multi-scope requests it is `null`.
- `use_cache` - optionally set to false to force a new token request.  The fetched
   token will still be cached for later `get_access_token` calls.

Notes

- If the application receives an authorization error when trying to use the resulting
  token, it should call [`clear_access_token_cache`](FirefoxAccount::clear_access_token_cache)
  before requesting a fresh token.