EXTENSION
HaapiTokenManager
public extension HaapiTokenManager
Methods
createClient(urlSession:)
func createClient(urlSession: URLSession? = nil) -> HaapiClient
Create a HaapiClient
instance that uses the HaapiTokenManager
's state (e.g. the HAAPI token and ...) for building outbound requests.
- Parameter urlSession: The actual URLSession instance that the created client will use to make HTTP requests.
When not provided, an
URLSession
instance configured in HaapiManagerToken is used. - Note: When building HaapiTokenManger and no
URLSession
was injected , then the default URLSession is anephemeral URLSession
Parameters
Name | Description |
---|---|
urlSession | The actual URLSession instance that the created client will use to make HTTP requests. When not provided, an URLSession instance configured in HaapiManagerToken is used. |
getHaapiTokenAsync(forceFresh:callbackDispatchQueue:dpopNonce:completionHandler:)
func getHaapiTokenAsync(forceFresh: Bool = false,
callbackDispatchQueue: DispatchQueue = DispatchQueue.main,
dpopNonce: String? = nil,
completionHandler: @escaping (Result<DpopAccessTokenInfo, HaapiError>) -> Void)
Obtain a HAAPI token asynchronously. Takes a completionHandler that is executed after the HAAPI token is obtained or an error occurred.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
- Parameter callbackDispatchQueue:the dispatch queue that is responsible for executing the process to obtain a HAAPI token. When not provided, it will use
DispatchQueue.main
- Parameter dpopNonce:The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method.
- Parameter completionHandler:handler that is called after a HAAPI token was successfully obtained.
Parameters
Name | Description |
---|---|
forceFresh | boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false. |
callbackDispatchQueue | the dispatch queue that is responsible for executing the process to obtain a HAAPI token. When not provided, it will use DispatchQueue.main |
dpopNonce | The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method. |
completionHandler | handler that is called after a HAAPI token was successfully obtained. |
getHaapiTokenAsync(forceFresh:callbackDispatchQueue:completionHandler:)
Obtain a HAAPI token asynchronously. Takes a completionHandler that is executed after the HAAPI token is obtained or an error occurred.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
- Parameter callbackDispatchQueue:the dispatch queue that is responsible for executing the process to obtain a HAAPI token.
When not provided, it will use
DispatchQueue.main
- Parameter completionHandler:handler that is called after a HAAPI token was successfully obtained.
getHaapiTokenAsync(forceFresh:callbackDispatchQueue:dpopNonce:completionHandler:)
Obtain a HAAPI token asynchronously. Takes a completionHandler that is executed after the HAAPI token is obtained or an error occurred.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
- Parameter callbackDispatchQueue:the dispatch queue that is responsible for executing the process to obtain a HAAPI token.
When not provided, it will use
DispatchQueue.main
- Parameter dpopNonce:The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method.
- Parameter completionHandler:handler that is called after a HAAPI token was successfully obtained.
getHaapiToken(forceFresh:dpopNonce:)
func getHaapiToken(forceFresh: Bool = false, dpopNonce: String? = nil) -> Result<DpopAccessTokenInfo, HaapiError>
Obtain a HAAPI token synchronously.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
- Parameter dpopNonce:The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method.
Parameters
Name | Description |
---|---|
forceFresh | boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false. |
dpopNonce | The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method. |
getHaapiToken(forceFresh:)
Obtain a HAAPI token synchronously.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
getHaapiToken(forceFresh:dpopNonce:)
Obtain a HAAPI token synchronously.
- Parameter forceFresh: boolean to indicate whether a new HAAPI token should be obtained even when the internal state already has a valid HAAPI token it can use. Defaults to false.
- Parameter dpopNonce:The most recent DPoP nonce. Any Identity Server response may contain a DPoP-Nonce header with a nonce string. This nonce needs be provided to all subsequent calls to this method.
close()
func close()
Closes this HAAPI Token Manager and frees the name of this manager to be used by another instance. It is an error to use this manager after calling close(), and will cause undefined behavior.
clearState()
func clearState()
Clears all state of this manager pertaining to DeviceCheck attestation and access tokens.