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
clientIdclient_id of the client
scopeset of scope(s) separated by space to request for the client; requesting scope set must be registered in the OAuth2 client
redirectUriredirect_uri in URL object as registered in the client
signoutRedirectUrioptional signout_redirect_uri in URL object as registered in the client
serverConfigServerConfig that OAuth2 Client will communicate to
thresholdthreshold 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
accessTokenAccessToken object to revoke
useRefreshTokenWhether to use refreshToken or not.
trueby defaultcompletionCompletion callback to notify the result of operation
-
Invalidates OIDC sessions
Declaration
Swift
@objc public func endSession(idToken: String, completion: @escaping CompletionCallback)Parameters
idTokenOIDC id_token
completionCompletion callback
-
Refreshes OAuth2 token set asynchronously with given refresh_token
Declaration
Swift
@objc public func refresh(refreshToken: String, completion: @escaping TokenCompletionCallback)Parameters
refreshTokenrefresh_token to be consumed for requesting new OAuth2 token set
completionCompletion 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 -> AccessTokenParameters
refreshTokenrefresh_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
tokenToken object (SSO Token) received from OpenAM through AuthService/Node authentication flow
completionCompletion 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
tokenToken object (SSO Token) received from OpenAM through AuthService/Node authentication flow
Return Value
AccessToken object if exchanging token was successful
View on GitHub