CLASS
OAuthTokenManager
Contents
- Methods
init(oauthTokenConfiguration:)
fetchAccessToken(with:dpop:additionalParameters:completionHandler:)
refreshAccessToken(with:additionalParameters:completionHandler:)
revokeAccessToken(with:completionHandler:)
revokeRefreshToken(with:completionHandler:)
@objcMembers public final class OAuthTokenManager: NSObject
OAuthTokenManager
instances are used to fetch or refresh an access token.
Methods
init(oauthTokenConfiguration:)
@objc public convenience init(oauthTokenConfiguration: OAuthTokenConfigurable)
Creates an OAuthTokenManager instance.
- Parameters:
- oauthTokenConfiguration: The configuration used to build this instance.
Parameters
Name | Description |
---|---|
oauthTokenConfiguration | The configuration used to build this instance. |
fetchAccessToken(with:dpop:additionalParameters:completionHandler:)
public func fetchAccessToken(with authorizationCode: String,
dpop: Dpop? = nil,
additionalParameters: [String: String]? = nil,
completionHandler: @escaping OAuthCompletion)
Fetches an access token using an authorization code grant.
If it succeeds then a SuccessfulTokenResponse
with the access token is returned.
If it fails either a ErrorTokenResponse
with the error reason is returned or the result has an Error
.
- Parameters:
- authorizationCode: The authorization code.
- dpop: The Dpop that was used during the Haapi flow. When it is required, this value has to be used via HaapiManager.dpop.
- additionalParameters: The additional parameters for the request body. The default value is nil.
- completionHandler: A completion handler that is called when
fetchAccessToken
is complete.
Parameters
Name | Description |
---|---|
authorizationCode | The authorization code. |
dpop | The Dpop that was used during the Haapi flow. When it is required, this value has to be used via HaapiManager.dpop. |
additionalParameters | The additional parameters for the request body. The default value is nil. |
completionHandler | A completion handler that is called when fetchAccessToken is complete. |
refreshAccessToken(with:additionalParameters:completionHandler:)
public func refreshAccessToken(with refreshToken: String,
additionalParameters: [String: String]? = nil,
completionHandler: @escaping OAuthCompletion)
Refresh an access token by providing a refresh token.
If it succeeds then a SuccessfulTokenResponse
with the access token is returned.
If it fails either an ErrorTokenResponse
with the error reason is returned or the result has an Error
.
- Parameters:
- refreshToken: The refresh token.
- additionalParameters: The additional parameters for the request body. The default value is nil.
- completionHandler: A completion handler that is called when
refreshAccessToken
is complete.
Parameters
Name | Description |
---|---|
refreshToken | The refresh token. |
additionalParameters | The additional parameters for the request body. The default value is nil. |
completionHandler | A completion handler that is called when refreshAccessToken is complete. |
revokeAccessToken(with:completionHandler:)
public func revokeAccessToken(with token: String, completionHandler: @escaping OAuthRevocationCompletion)
Revokes an access token.
If it succeeds then a successfulRevocation
is returned.
If it fails an error
response is returned containing an Error
.
- Parameters:
- token: The token to be revoked.
- completionHandler: A completion handler that is called when
revokeAccessToken
is complete.
Parameters
Name | Description |
---|---|
token | The token to be revoked. |
completionHandler | A completion handler that is called when revokeAccessToken is complete. |
revokeRefreshToken(with:completionHandler:)
public func revokeRefreshToken(with token: String,
completionHandler: @escaping OAuthRevocationCompletion)
Revokes a refresh token.
If it succeeds then a success
is returned.
If it fails an error
response is returned containing an Error
.
- Parameters:
- token: The token to be revoked.
- completionHandler: A completion handler that is called when
revokeRefreshToken
is complete.
Parameters
Name | Description |
---|---|
token | The token to be revoked. |
completionHandler | A completion handler that is called when revokeRefreshToken is complete. |