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

OAuthAccount

interface OAuthAccount : AutoCloseable (source)

Facilitates testing consumers of FirefoxAccount.

Functions

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.
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.
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.
migrateFromSessionTokenAsync abstract fun migrateFromSessionTokenAsync(sessionToken: String, kSync: String, kXCS: String): Deferred<Boolean>
Attempts to migrate from an existing session token without user input
registerPersistenceCallback abstract fun registerPersistenceCallback(callback: StatePersistenceCallback): Unit
Registers a callback for when the account state gets persisted
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.

Inheritors

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