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


class FirefoxAccount : OAuthAccount (source)

FirefoxAccount represents the authentication state of a client.


Name Summary
<init> FirefoxAccount(config: ServerConfig, persistCallback: PersistCallback? = null, crashReporter: CrashReporting? = null)
Construct a FirefoxAccount from a Config, a clientId, and a redirectUri.


Name Summary
authErrorDetected fun authErrorDetected(): Unit
Call this whenever an authentication error was encountered while using an access token issued by getAccessTokenAsync.
authorizeOAuthCodeAsync fun authorizeOAuthCodeAsync(clientId: String, scopes: Array<String>, state: String, accessType: AccessType): <ERROR CLASS>
Provisions a scoped OAuth code for a given clientId and the passed scopes.
beginOAuthFlowAsync fun beginOAuthFlowAsync(scopes: Set<String>): <ERROR CLASS>
Constructs a URL used to begin the OAuth flow for the requested scopes and keys.
beginPairingFlowAsync fun beginPairingFlowAsync(pairingUrl: String, scopes: Set<String>): <ERROR CLASS>
Constructs a URL used to begin the pairing flow for the requested scopes and pairingUrl.
checkAuthorizationStatusAsync fun checkAuthorizationStatusAsync(singleScope: String): <ERROR CLASS>
This method should be called when a request made with an OAuth token failed with an authentication error. It will re-build cached state and perform a connectivity check.
close fun close(): Unit
completeOAuthFlowAsync fun completeOAuthFlowAsync(code: String, state: String): <ERROR CLASS>
Authenticates the current account using the code and state parameters obtained via the OAuth flow initiated by beginOAuthFlowAsync.
copyFromSessionTokenAsync fun copyFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): <ERROR CLASS>
Attempts to migrate from an existing session token without user input. New session token will be created.
deviceConstellation fun deviceConstellation(): DeviceConstellation
Returns the device constellation for the current account
disconnectAsync fun disconnectAsync(): <ERROR CLASS>
Reset internal account state and destroy current device record. Use this when device record is no longer relevant, e.g. while logging out. On success, other devices will no longer see the current device in their device lists.
getAccessTokenAsync fun getAccessTokenAsync(singleScope: String): <ERROR CLASS>
Tries to fetch an access token for the given scope.
getConnectionSuccessURL fun getConnectionSuccessURL(): String
Fetches the connection success url.
getCurrentDeviceId fun getCurrentDeviceId(): String?
Returns current FxA Device ID for an authenticated account.
getPairingAuthorityURL fun getPairingAuthorityURL(): String
Get the pairing URL to navigate to on the Authority side (typically a computer).
getProfileAsync fun getProfileAsync(ignoreCache: Boolean): <ERROR CLASS>
Fetches the profile object for the current client either from the existing cached state or from the server (requires the client to have access to the profile scope).
getSessionToken fun getSessionToken(): String?
Returns session token for an authenticated account.
getTokenServerEndpointURL fun getTokenServerEndpointURL(): String
Fetches the token server endpoint, for authentication using the SAML bearer flow.
isInMigrationState fun isInMigrationState(): InFlightMigrationState
Checks if there’s a migration in-flight. An in-flight migration means that we’ve tried to migrate via either migrateFromSessionTokenAsync or copyFromSessionTokenAsync, and failed for intermittent (e.g. network) reasons. When an in-flight migration is present, we can retry using retryMigrateFromSessionTokenAsync.
migrateFromSessionTokenAsync fun migrateFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): <ERROR CLASS>
Attempts to migrate from an existing session token without user input. Passed-in session token will be reused.
registerPersistenceCallback fun registerPersistenceCallback(callback: StatePersistenceCallback): Unit
Registers a callback for when the account state gets persisted
retryMigrateFromSessionTokenAsync fun retryMigrateFromSessionTokenAsync(): Deferred<<ERROR CLASS>?>
Retries an in-flight migration attempt.
toJSONString fun toJSONString(): String
Serializes 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

Name Summary
fromJSONString fun fromJSONString(json: String, persistCallback: PersistCallback? = null): FirefoxAccount
Restores the account’s authentication state from a JSON string produced by FirefoxAccount.toJSONString.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.