OAuth2Client
@objc(FROAuth2Client)
public class OAuth2Client : NSObject, Codable
OAuth2 client object represents OAuth2 client, and provides methods related to OAuth2 protocol
-
Designated initialization method for OAuth2 Client
Declaration
Swift
@objc public init(clientId: String, scope: String, redirectUri: URL, signoutRedirectUri: URL? = nil, serverConfig: ServerConfig, threshold: Int = 60)
Parameters
clientId
client_id of the client
scope
set of scope(s) separated by space to request for the client; requesting scope set must be registered in the OAuth2 client
redirectUri
redirect_uri in URL object as registered in the client
signoutRedirectUri
optional signout_redirect_uri in URL object as registered in the client
serverConfig
ServerConfig that OAuth2 Client will communicate to
threshold
threshold in seconds to refresh access_token before it actually expires
-
Revokes access_token and any associated token(s)
Declaration
Swift
@objc public func revoke(accessToken: AccessToken, useRefreshToken: Bool = true, completion: @escaping CompletionCallback)
Parameters
accessToken
AccessToken object to revoke
useRefreshToken
Whether to use refreshToken or not.
true
by defaultcompletion
Completion callback to notify the result of operation
-
Invalidates OIDC sessions
Declaration
Swift
@objc public func endSession(idToken: String, completion: @escaping CompletionCallback)
Parameters
idToken
OIDC id_token
completion
Completion callback
-
Refreshes OAuth2 token set asynchronously with given refresh_token
Declaration
Swift
@objc public func refresh(refreshToken: String, completion: @escaping TokenCompletionCallback)
Parameters
refreshToken
refresh_token to be consumed for requesting new OAuth2 token set
completion
Completion callback to notify the result of operation with AccessToken object or an error
-
Refreshes OAuth2 token set synchronously with given refresh_token
Important Note
This method is synchronous operation; please be aware consequences, and perform this method in Main thread if necessary.
Throws
AuthError or TokenErrorDeclaration
Swift
@objc public func refreshSync(refreshToken: String) throws -> AccessToken
Parameters
refreshToken
refresh_token to be consumed for requesting new OAuth2 token set
Return Value
AccessToken object if refreshing token was successful
-
Exchanges SSOToken received from OpenAM asynchronously to OAuth2 token set using OAuth2 Authorization Code flow.
Declaration
Swift
@objc public func exchangeToken(token: Token, completion: @escaping TokenCompletionCallback)
Parameters
token
Token object (SSO Token) received from OpenAM through AuthService/Node authentication flow
completion
Completion callback which returns set of token(s), or error upon completion of request
-
Exchanges SSOToken received from OpenAM synchronously to OAuth2 token set using OAuth2 Authorization Code flow.
Important Note
This method is synchronous operation; please be aware consequences, and perform this method in Main thread if necessary.
Throws
AuthError or TokenErrorDeclaration
Swift
public func exchangeTokenSync(token: Token) throws -> AccessToken?
Parameters
token
Token object (SSO Token) received from OpenAM through AuthService/Node authentication flow
Return Value
AccessToken object if exchanging token was successful