UnbluAuthHelper
public class UnbluAuthHelper
-
Sends a POST request to the Unblu backend to create an authentication token using the provided credentials.
Declaration
Swift
public static func createAuthenticationToken(with configuration: UnbluClientConfiguration, username: String?, password: String?, success: @escaping (AuthenticationTokenCreationResult) -> Void,failure: ((String) -> Void)?)Parameters
configurationThe Unblu client configuration containing the base URL and entry path.
usernameThe username to authenticate.
passwordThe password to authenticate.
successClosure called with the authentication token string upon successful response.
failureOptional closure called with an error message string if the request fails.
-
Sends a GET request to the Unblu backend using an existing authentication token, and returns the result string and authentication cookies.
Declaration
Swift
public static func authenticateWithToken(with configuration: UnbluClientConfiguration, authenticationToken: String, success: @escaping (String, [String: String]) -> Void,failure: ((String) -> Void)?)Parameters
configurationThe Unblu client configuration.
authenticationTokenA valid one-time token used for authentication.
successClosure called with the raw result string and a dictionary of cookies upon success.
failureOptional closure called with an error message string if the request fails.
-
Authenticates with an existing token and completes the 2FA login flow.
This method first authenticates using the provided token to retrieve cookies, then displays a two-factor authentication web view if the authentication is successful.
Declaration
Swift
public static func authenticateWithTokenAndLoginWith2FA(with configuration: UnbluClientConfiguration, token: String, uiConfig: UnbluTwoFactorAuthErrorUIConfig = .init(), completion: @escaping (Bool, [UnbluCookie]?) -> Void)Parameters
configurationThe Unblu client configuration to use.
tokenThe authentication token obtained previously.
uiConfigThe
UnbluTwoFactorAuthUIConfigused to configure the error window’s button titles and colors.completionA closure called when the process is completed. Returns a Boolean indicating success, and an array of authentication cookies (or
nilon failure). -
Performs a full login flow including authentication token creation and two-factor authentication.
This method creates an authentication token using the provided username and password, authenticates with that token, and if needed, presents a two-factor authentication web view.
Declaration
Swift
public static func createAuthTokenAndLoginWith2FA(with configuration: UnbluClientConfiguration, username: String, password: String, uiConfig: UnbluTwoFactorAuthErrorUIConfig = .init(), completion: @escaping (Bool, [UnbluCookie]?) -> Void)Parameters
configurationThe Unblu client configuration to use.
usernameThe username for authentication.
passwordThe password for authentication.
uiConfigThe
UnbluTwoFactorAuthUIConfigused to configure the error window’s button titles and colors.completionA closure called when the process is completed. Returns a Boolean indicating success, and an array of authentication cookies (or
nilon failure). -
Declaration
Swift
public static func getAuthToken(preferencesStorage: UnbluPreferencesStorage) -> String?