FirefoxAccount

Object representing the signed-in state of an application.

The FirefoxAccount object is the main interface provided by this crate. It represents the signed-in state of an application that may be connected to user's Firefox Account, and provides methods for inspecting the state of the account and accessing other services on behalf of the user.

Constructors

Link copied to clipboard
constructor(config: FxaConfig)

Create a new `FirefoxAccount` instance, not connected to any account.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Create a new OAuth authorization code using the stored session token.

Link copied to clipboard
open override fun beginOauthFlow(scopes: List<String>, entrypoint: String, service: String): String

Initiate a web-based OAuth sign-in flow.

Link copied to clipboard
open override fun beginPairingFlow(pairingUrl: String, scopes: List<String>, entrypoint: String, service: String): String

Initiate a device-pairing sign-in flow.

Link copied to clipboard

Check authorization status for this application.

Link copied to clipboard
open override fun clearAccessTokenCache()

Clear the access token cache in response to an auth failure.

Link copied to clipboard
open override fun clearDeviceName()

Clear any custom display name used for this application instance.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun closeTabs(targetDeviceId: String, urls: List<String>): CloseTabsResult

Use device commands to close one or more tabs on another device.

Link copied to clipboard
open override fun completeOauthFlow(code: String, state: String)

Complete an OAuth flow.

Link copied to clipboard
open override fun destroy()
Link copied to clipboard
open override fun disconnect()

Disconnect from the user's account.

Link copied to clipboard
open override fun ensureCapabilities(supportedCapabilities: List<DeviceCapability>): LocalDevice

Ensure that the device record has a specific set of capabilities.

Link copied to clipboard
open override fun gatherTelemetry(): String

Collect and return telemetry about incoming and outgoing device commands.

Link copied to clipboard
open override fun getAccessToken(scope: String, useCache: Boolean): AccessTokenInfo

Get a short-lived OAuth access token for the user's account.

Link copied to clipboard
open override fun getAttachedClients(): List<AttachedClient>

Get the list of all client applications attached to the user's account.

Link copied to clipboard
open override fun getAuthState(): FxaRustAuthState

Get the high-level authentication state of the client

Link copied to clipboard
open override fun getConnectionSuccessUrl(): String

Get a URL which shows a "successfully connceted!" message.

Link copied to clipboard
open override fun getCurrentDeviceId(): String

Get the device id registered for this application.

Link copied to clipboard
open override fun getDevices(ignoreCache: Boolean): List<Device>

Get the list of devices registered on the user's account.

Link copied to clipboard
open override fun getManageAccountUrl(entrypoint: String): String

Get a URL at which the user can manage their account and profile data.

Link copied to clipboard
open override fun getManageDevicesUrl(entrypoint: String): String

Get a URL at which the user can manage the devices connected to their account.

Link copied to clipboard
open override fun getPairingAuthorityUrl(): String

Get the URL at which to begin a device-pairing signin flow.

Link copied to clipboard
open override fun getProfile(ignoreCache: Boolean): Profile

Get profile information for the signed-in user, if any.

Link copied to clipboard
open override fun getSignedInUserForWebChannel(): String?

Returns a complete signedInUser JSON object for a WebChannel fxaccounts:fxa_status response, embedding the session token privately. Email and uid come from the cached profile in internal state. Returns null if no session token is set.

Link copied to clipboard
open override fun getState(): FxaState

Get the current state

Link copied to clipboard
open override fun getTokenServerEndpointUrl(): String

Get the URL at which to access the user's sync data.

Link copied to clipboard
open override fun handlePushMessage(payload: String): AccountEvent

Process and respond to a server-delivered account update message

Link copied to clipboard
open override fun handleWebChannelLogin(jsonPayload: String)

Stores anything necessary from a WebChannel login JSON payload. This includes the session token, but that is abstracted because the consuming apps should not be aware of the specific payload format returned, nor should they get access to the session token directly if possible. The json_payload is the data object from the fxaccounts:login WebChannel command.

Link copied to clipboard
open override fun handleWebChannelPasswordChange(jsonPayload: String)

Handle a WebChannel password-change notification by exchanging the new session token for a new refresh token via a network call. The json_payload is the data object from the fxaccounts:change_password WebChannel command.

Link copied to clipboard
open override fun initializeDevice(name: String, deviceType: DeviceType, supportedCapabilities: List<DeviceCapability>): LocalDevice

Create a new device record for this application.

Link copied to clipboard
open override fun onAuthIssues()

Update the state based on authentication issues.

Link copied to clipboard

Poll the server for any pending device commands.

Link copied to clipboard
open override fun processEvent(event: FxaEvent): FxaState

Process an event (login, logout, etc).

Link copied to clipboard
open override fun sendSingleTab(targetDeviceId: String, title: String, url: String, isPrivate: Boolean)

Use device commands to send a single tab to another device.

Link copied to clipboard
open override fun setDeviceName(displayName: String): LocalDevice

Update the display name used for this application instance.

Link copied to clipboard
open override fun setPushSubscription(subscription: DevicePushSubscription): LocalDevice

Set or update a push subscription endpoint for this device.

Link copied to clipboard
open override fun simulateNetworkError()

Used by the application to test auth token issues

Link copied to clipboard

Used by the application to test auth token issues

Link copied to clipboard

Used by the application to test auth token issues

Link copied to clipboard
open override fun toJson(): String

Save current state to a JSON string.