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

FirefoxAccount

class FirefoxAccount : RustObject<RawFxAccount> (source)

FirefoxAccount represents the authentication state of a client.

Parameters

Constructors

<init>

FirefoxAccount(config: Config, clientId: String, redirectUri: String)FirefoxAccount(rawPointer: RawFxAccount?)

FirefoxAccount represents the authentication state of a client.

Properties

rawPointer

var rawPointer: RawFxAccount?

Inherited Properties

isConsumed

val isConsumed: Boolean

Functions

beginOAuthFlow

fun beginOAuthFlow(scopes: Array<String>, wantsKeys: Boolean): FxaResult<String>

Constructs a URL used to begin the OAuth flow for the requested scopes and keys.

beginPairingFlow

fun beginPairingFlow(pairingUrl: String, scopes: Array<String>): FxaResult<String>

completeOAuthFlow

fun completeOAuthFlow(code: String, state: String): FxaResult<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.

destroy

fun destroy(p: RawFxAccount): Unit

getOAuthToken

fun getOAuthToken(scopes: Array<String>): FxaResult<OAuthInfo>

Fetches a new access token for the desired scopes using an internally stored refresh token.

getProfile

fun getProfile(ignoreCache: Boolean): FxaResult<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(): FxaResult<Profile>

Convenience method to fetch the profile from a cached account by default, but fall back to retrieval from the server.

getSyncKeys

fun getSyncKeys(): SyncKeys

Fetches keys for encryption/decryption of Firefox Sync data.

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.

Inherited Functions

close

open fun close(): Unit

consumePointer

fun consumePointer(): T

validPointer

fun validPointer(): T

Companion Object Functions

from

fun from(config: Config, clientId: String, redirectUri: String, webChannelResponse: String): FxaResult<FirefoxAccount>

fromJSONString

fun fromJSONString(json: String): FxaResult<FirefoxAccount>

Restores the account's authentication state from a JSON string produced by FirefoxAccount.toJSONString.