AgsAuth
open class AgsAuth
AeroGear Services Auth SDK
Allows users to perform login/logout actions against an Keycloak service provisioned by the AeroGear mobile service on OpenShift.
### Example ### initialise the authentication configuration service and configure the Auth SDK
let authConfig = AuthenticationConfig(redirectURL: "com.youapp://callback")
AgsAuth.instance.configure(authConfig: authConfig)
Login using the configured Auth SDK
AgsAuth.instance.login()
-
instance of the Auth SDK
Declaration
Swift
public static let instance: <<error type>> -
Errors generated by the auth module
See moreDeclaration
Swift
public enum Errors : Error -
Configure the Auth SDK.
Important
This function should be called before any other functions are invoked. Only need to call this once.
Throws
a
noServiceConfigurationFounderror if no authentication configuration was found in themobileConfigused to initialise the Auth SDKDeclaration
Swift
public func configure(authConfig: AuthenticationConfig) throwsParameters
authConfigConfiguration options for the auth module
-
Perform user login action.
Throws
aserviceNotConfigurederror if the Auth SDK has not been configuredDeclaration
Swift
public func login(presentingViewController: UIViewController, onCompleted: @escaping (_ user: User?, _ error: Error?) -> Void) throwsParameters
presentingViewControllerthe ViewController that initiates the login process
onCompletedcallback function that will be invoked when the login is finished
userthe user returned in the
onCompletedcallback function. Will be nil if login failederrorthe error returned in the
onCompletedcallback function. Will be nil if login was successful -
Resume the authentication process.
This function should be invoked when the user has finished logging in via the browser and redirected back to the app that started the login.
Throws
a
serviceNotConfigurederror if the Auth SDK has not been configuredDeclaration
Swift
public func resumeAuth(url: URL) throws -> BoolParameters
urlThe redirect url passed backed from the login process
Return Value
true if the login process can be resumed, false otherwise
-
Perform the logout action.
Throws
a
serviceNotConfigurederror if the Auth SDK has not been configured or anoLoggedInUserErrorif no user is logged inDeclaration
Swift
public func logout(onCompleted: @escaping (_ error: Error?) -> Void) throwsParameters
onCompletedcallback function that will be invoked when the logout process has completed
errorthe
serviceNotConfigurederror returned in theonCompletedcallback function -
Get the current logged in user.
Throws
a
serviceNotConfigurederror if the Auth SDK has not been configuredDeclaration
Swift
public func currentUser() throws -> User?Return Value
the user that is currently logged in
AgsAuth Class Reference