android-components / mozilla.components.concept.sync / OAuthAccount


interface OAuthAccount : AutoCloseable (source)

Facilitates testing consumers of FirefoxAccount.


Name Summary
authorizeOAuthCodeAsync abstract fun authorizeOAuthCodeAsync(clientId: String, scopes: Array<String>, state: String, accessType: AccessType = AccessType.ONLINE): Deferred<String?>
Provisions a scoped OAuth code for a given clientId and the passed scopes.
beginOAuthFlowAsync abstract fun beginOAuthFlowAsync(scopes: Set<String>): Deferred<AuthFlowUrl?>
Constructs a URL used to begin the OAuth flow for the requested scopes and keys.
beginPairingFlowAsync abstract fun beginPairingFlowAsync(pairingUrl: String, scopes: Set<String>): Deferred<AuthFlowUrl?>
Constructs a URL used to begin the pairing flow for the requested scopes and pairingUrl.
checkAuthorizationStatusAsync abstract fun checkAuthorizationStatusAsync(singleScope: String): Deferred<Boolean?>
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.
completeOAuthFlowAsync abstract fun completeOAuthFlowAsync(code: String, state: String): Deferred<Boolean>
Authenticates the current account using the code and state parameters obtained via the OAuth flow initiated by beginOAuthFlowAsync.
copyFromSessionTokenAsync abstract fun copyFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): Deferred<<ERROR CLASS>?>
Attempts to migrate from an existing session token without user input. New session token will be created.
deviceConstellation abstract fun deviceConstellation(): DeviceConstellation
Returns the device constellation for the current account
disconnectAsync abstract fun disconnectAsync(): Deferred<Boolean>
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 abstract fun getAccessTokenAsync(singleScope: String): Deferred<AccessTokenInfo?>
Tries to fetch an access token for the given scope.
getCurrentDeviceId abstract fun getCurrentDeviceId(): String?
Returns current FxA Device ID for an authenticated account.
getPairingAuthorityURL abstract fun getPairingAuthorityURL(): String
Get the pairing URL to navigate to on the Authority side (typically a computer).
getProfileAsync abstract fun getProfileAsync(ignoreCache: Boolean = false): Deferred<Profile?>
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 abstract fun getSessionToken(): String?
Returns session token for an authenticated account.
getTokenServerEndpointURL abstract fun getTokenServerEndpointURL(): String
Fetches the token server endpoint, for authentication using the SAML bearer flow.
isInMigrationState abstract 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 abstract fun migrateFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): Deferred<<ERROR CLASS>?>
Attempts to migrate from an existing session token without user input. Passed-in session token will be reused.
registerPersistenceCallback abstract fun registerPersistenceCallback(callback: StatePersistenceCallback): Unit
Registers a callback for when the account state gets persisted
retryMigrateFromSessionTokenAsync abstract fun retryMigrateFromSessionTokenAsync(): Deferred<<ERROR CLASS>?>
Retries an in-flight migration attempt.
toJSONString abstract 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.

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.


Name Summary
FirefoxAccount class FirefoxAccount : OAuthAccount
FirefoxAccount represents the authentication state of a client.