android-components / mozilla.components.service.fxa / FirefoxAccount

# FirefoxAccount

`class FirefoxAccount : AutoCloseable` (source)

FirefoxAccount represents the authentication state of a client.

### Constructors

<init> | `FirefoxAccount(config: Config, clientId: String, redirectUri: String)` Construct a FirefoxAccount from a Config, a clientId, and a redirectUri.

### Functions

beginOAuthFlow | `fun beginOAuthFlow(scopes: Array<String>, wantsKeys: Boolean): Deferred<String>` Constructs a URL used to begin the OAuth flow for the requested scopes and keys.
beginPairingFlow | `fun beginPairingFlow(pairingUrl: String, scopes: Array<String>): Deferred<String>`
close | `fun close(): Unit`
completeOAuthFlow | `fun completeOAuthFlow(code: String, state: String): Deferred<OAuthInfo>` Authenticates the current account using the code and state parameters fetched from the redirect URL reached after completing the sign in flow triggered by beginOAuthFlow.
getCachedOAuthToken | `fun getCachedOAuthToken(scopes: Array<String>): Deferred<OAuthInfo?>` Tries to fetch a cached access token for the given scope.
getProfile | `fun getProfile(ignoreCache: Boolean): Deferred<Profile>` Fetches the profile object for the current client either from the existing cached account, or from the server (requires the client to have access to the profile scope). `fun getProfile(): Deferred<Profile>` Convenience method to fetch the profile from a cached account by default, but fall back to retrieval from the server.
getTokenServerEndpointURL | `fun getTokenServerEndpointURL(): String` Fetches the token server endpoint, for authentication using the SAML bearer flow.
toJSONString | `fun toJSONString(): String` Saves the current account's authentication state as a JSON string, for persistence in the Android KeyStore/shared preferences. The authentication state can be restored using FirefoxAccount.fromJSONString.

### Companion Object Functions

fromJSONString | `fun fromJSONString(json: String): FirefoxAccount` Restores the account's authentication state from a JSON string produced by FirefoxAccount.toJSONString.