AuthenticationMode

public class AuthenticationMode
extension AuthenticationMode: NativeBase
extension AuthenticationMode: Hashable

This is a bearer authentication mode which adds or does not add a header (“Authorization”, “Bearer $Token”) to each online request of the module the object is added to. The token (if used) can be provided or is retrieved via key/secret from a dedicated backend.

  • This lambda is used to retrieve access token in synchronous manner. It returns the access token or null if it is not set. The lambda is called each time the access token is needed and it is executed on the main thread of the application.

    Declaration

    Swift

    public typealias AccessTokenProvider = () -> String?

    Return Value

    Access token in case it is set or null otherwise.

  • SDK will pass access token as a Bearer.

    Declaration

    Swift

    public static func withToken(accessToken: String) -> AuthenticationMode

    Parameters

    accessToken

    Access token

    Return Value

    Instance of AuthenticationMode configured to use token

  • SDK will use access token provider to retrieve access token.

    Declaration

    Swift

    public static func withTokenProvider(tokenProvider: @escaping AuthenticationMode.AccessTokenProvider) -> AuthenticationMode

    Parameters

    tokenProvider

    Access token provider

    Return Value

    Instance of AuthenticationMode configured to use token provider

  • Assumes the authentication is provided by the client.

    Declaration

    Swift

    public static func withExternal() -> AuthenticationMode

    Return Value

    Instance of AuthenticationMode configured to use externally provided authentication

  • SDK will authenticate with access key id access key secret to obtain authentication token.

    Declaration

    Swift

    public static func withKeySecret(accessKeyId: String, accessKeySecret: String) -> AuthenticationMode

    Parameters

    accessKeyId

    The access key id

    accessKeySecret

    The access key secret

    Return Value

    Instance of AuthenticationMode configured to use key ID and secret