IdentityProvider

protocol IdentityProvider : Sendable

Interface required to participate in Identity flows.

NOTE: Method calls are externally synchronized, but may occur on any thread.

  • Returns the AccountID of the current active User.

    If there is no active User, a sign-in may be triggered. In that case, the provided scopes and deviceToken may be used to request authorization at the same time.

    Parameters:

    • scopes: Required OAuth scopes for authorization.
    • deviceToken: Identifier unique to this physical device

    Returns nil if there is no active User and the SDK should fallback to another IdentityProvider.

    Throws if a User did not sign in.

    Declaration

    Swift

    func activeAccount(scopes: Set<String>, deviceToken: String) async throws -> AccountID?

    Parameters

    scopes

    Required OAuth scopes for authorization.

    deviceToken

    Identifier unique to this physical device

  • Callback to request authorization for data access.

    If no additional steps are needed (or consent is already granted for the specified account), implementations can simply return nil. May be called periodically when Device Attestation needs to be renewed.

    Parameters:

    • accountID: The accountID of the requesting User.
    • scopes: Required OAuth scopes for authorization.
    • deviceToken: Identifier unique to this physical device

    Returns an optional challenge. If returned, the challenge will be used for verification.

    Throws if consent is not granted, or some other error prevents the request.

    Declaration

    Swift

    func requestAuthorization(for accountID: AccountID, scopes: Set<String>, deviceToken: String) async throws -> Data?

    Parameters

    scopes

    Required OAuth scopes for authorization.

    deviceToken

    Identifier unique to this physical device

  • Called by the SDK to perform something on a User’s behalf.

    NOTE: May be called from any thread.

    Parameters:

    • accountID - The accountID for the requesting User.
    • scopes: Required OAuth scopes for authorization. Returns a current access token, may refresh if needed. Throws if access is not granted.

    Declaration

    Swift

    func accessToken(for accountID: AccountID, scopes: Set<String>) async throws -> String

    Parameters

    scopes

    Required OAuth scopes for authorization. Returns a current access token, may refresh if needed. Throws if access is not granted.