iOS HMOAuthResult

HMOAuthResult is an enum representing the result of an OAuth request, returned asynchronously.

Table of Contents

Values

Authentication encountered an error

Declaration

.error(HMOAuthError, state: String?)

Parameters

error

(HMOAuthError) the error encountered

state

(String) optional string representing the state

Discussion

State is set when starting the OAuth process (similar to context) with -launchAuthFlow.

Read More

Example

import HMKit

let error: HMOAuthError = .accessDenied
let result: HMOAuthResult = .error(error, state: "testing")

// A usage example
if case .error(let error, let state) = result {
    print("Request failed, error: \(error), state: \(state)")
}

Authentication was successful and the access token was received

Declaration

.success(accessToken: String, state: String?)

Parameters

accessToken

(String) the access token

state

(String) optional string representing the state

Discussion

State is set when starting the OAuth process (similar to context) with HMOAuth.launchAuthFlow.
The access token should be used in HMTelematics.downloadAccessCertificate to download the certificates

Read More

Example

import HMKit

let token: String = "imzDKyM-oklBaSIIv...EiXqBy3eBum9QLcMTrqzYg"
let result: HMOAuthResult = .success(accessToken: token, state: "testing")

// A usage example
if case .success(let token, let state) = result {
    print("Access token received, state: \(state)")

    // Access Token should be passed on to download the certificate
    try HMTelematics.downloadAccessCertificate(accessToken: token) { /* code */ }
}