OAuthContext
@objc
public final class OAuthContext : NSObject
The OAuthContext
implements the Resource Owner Password Credentials (ROPC) Grant and Authorization Code Grant as the calling client to an OAuth authorization server. The resource owner is suitable in cases where the resource owner has a trust relationship with the client. The authorization code grant flow is suitable when the authorization code has been generated using an alternate factor, such as a desktop browser.
-
Returns the shared instance of the object.
Declaration
Swift
@objc public static let shared: OAuthContext
-
Get or set the session delegate that handles authentication requests. Refer to URLSessionDelegate. Default is
nil
.Declaration
Swift
@objc public var serverTrustDelegate: URLSessionDelegate?
-
The timeout interval for the request, in seconds. The default is 30 seconds.
Declaration
Swift
@objc public var timeoutInterval: TimeInterval
-
A
[String]
of scopes to be authorized.Remark
For mobile multi-factor authentication (MMFA) registration using the ROPC flow, a scope must contain mmfaAuthn. For OpenID Connect registration using ROPC, a scope must contain oidc.Declaration
Swift
@objc public var scope: [String]?
-
The secret between the service and the client app.
Declaration
Swift
@objc public var clientSecret: String?
-
The dictionary to add additional headers to the HTTP request.
Declaration
Swift
@objc public var headers: [String : String]
-
Acquires a security token from the token endpoint using OAuth resource owner password grant type (ROPC).
Declaration
Swift
@objc public func getAccessToken(_ endpointUrl: String, _ clientId: String, username: String, password: String, completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
username
The username.
password
The password for username.
completion
The function delegate that is invoked with a
OAuthResult
. -
Acquires a security token from the token endpoint using OAuth resource owner password grant type.
Declaration
Swift
@objc public func getAccessToken(_ endpointUrl: String, _ clientId: String, username: String, password: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
username
The username.
password
The password for username.
params
Additional parameters associated with the request body.
completion
The function delegate that is invoked with a
OAuthResult
. -
Acquires a security token from the token endpoint using OAuth authorization_code grant type.
Declaration
Swift
@objc public func getAccessToken(_ endpointUrl: String, _ clientId: String, code: String, completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
code
The authorisation code provided by the OAuth endpoint.
completion
The function delegate that is invoked with a
OAuthResult
. -
Acquires a security token from the token endpoint using OAuth authorization_code grant type.
Declaration
Swift
@objc public func getAccessToken(_ endpointUrl: String, _ clientId: String, code: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
code
The authorisation code provided by the OAuth endpoint.
params
Additional parameters associated with the request body.
completion
The function delegate that is invoked with a
OAuthResult
. -
Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.
Declaration
Swift
@objc public func refreshAccessToken(_ endpointUrl: String, _ clientId: String, refreshToken: String, completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
refreshToken
The refresh token.
completion
The function delegate that is invoked with a
OAuthResult
. -
Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.
Declaration
Swift
@objc public func refreshAccessToken(_ endpointUrl: String, _ clientId: String, refreshToken: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())
Parameters
endpointUrl
The location to the OAuth endpoint.
clientId
The unique identifier between the service and the client app.
refreshToken
The refresh token.
params
Additional parameters associated with the request body.
completion
The function delegate that is invoked with a
OAuthResult
.