OAuthContext

public final class OAuthContext

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

    public static let shared = OAuthContext()
  • Get or set the session delegate that handles authentication requests. Refer to URLSessionDelegate. Default is nil.

    Declaration

    Swift

    public var serverTrustDelegate: URLSessionDelegate?
  • The timeout interval for the request, in seconds. The default is 30 seconds.

    Declaration

    Swift

    public var timeoutInterval: TimeInterval = 30.0
  • 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

    public var scope: [String]?
  • The secret between the service and the client app.

    Declaration

    Swift

    public var clientSecret: String?
  • The dictionary to add additional headers to the HTTP request.

    Declaration

    Swift

    public var headers = [String: String]()
  • Acquires a security token from the token endpoint using OAuth resource owner password grant type (ROPC).

    Declaration

    Swift

    public func getAccessToken(_ endpointUrl: String, _ clientId: String, username: String, password: String, completion: @escaping (OAuthResult) -> ())
  • Acquires a security token from the token endpoint using OAuth resource owner password grant type.

    Declaration

    Swift

    public func getAccessToken(_ endpointUrl: String, _ clientId: String, username: String, password: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())
  • Acquires a security token from the token endpoint using OAuth authorization_code grant type.

    Declaration

    Swift

    public func getAccessToken(_ endpointUrl: String, _ clientId: String, code: String, completion: @escaping (OAuthResult) -> ())
  • Acquires a security token from the token endpoint using OAuth authorization_code grant type.

    Declaration

    Swift

    public func getAccessToken(_ endpointUrl: String, _ clientId: String, code: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())
  • Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.

    Declaration

    Swift

    public func refreshAccessToken(_ endpointUrl: String, _ clientId: String, refreshToken: String, completion: @escaping (OAuthResult) -> ())
  • Acquires a security refresh token from the token endpoint using OAuth refresh_token grant type.

    Declaration

    Swift

    public func refreshAccessToken(_ endpointUrl: String, _ clientId: String, refreshToken: String, params: [String: Any], completion: @escaping (OAuthResult) -> ())