RestToken

public class RestToken

A RestToken object retrieves, stores, and refreshes an authentication token. The token is retrieved at a particular URL using basic authentication credentials (i.e. username and password).

  • The string authentication token.

    Declaration

    Swift

    public var token: String?
  • Denotes whether the token is refreshing.

    Declaration

    Swift

    public var isRefreshing: Bool
  • Denotes the number of retries.

    Declaration

    Swift

    public var retries: Int
  • Create a RestToken.

    Declaration

    Swift

    public init(tokenURL: String, username: String, password: String)

    Parameters

    tokenURL

    The URL that shall be used to obtain a token.

    username

    The username credential used to obtain a token.

    password

    The password credential used to obtain a token.

  • Refresh the authentication token.

    Declaration

    Swift

    public func refreshToken(
        failure: ((Error) -> Void)? = nil,
        success: (() -> Void)? = nil)

    Parameters

    failure

    A function executed if an error occurs.

    success

    A function executed after a new token is retrieved.