# Authentication API URL: https://developers.vsee.com/guides/clinickit/ios-authentication-api `AuthenticateService` signs users in to VSee Clinic and manages their session. ### Login `userLogin` signs a user in with a username and password. ```swift public func userLogin(userName: String, password: String, success: @escaping() -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `userName` | `String` | The user's username. | | `password` | `String` | The user's password. | | `success` | `Closure` | Called when sign-in succeeds. | | `failure` | `Closure` | Called when sign-in fails, with the error. | #### Example usage ```swift AuthenticateService.shared.userLogin(userName: username, password: password, success: { // Authentication successful // Perform any actions or navigate to the next screen }, failure: { error in // Authentication failed // Handle the error or display an error message }) ``` ### Guest login `guestLogin` signs a guest in with a first and last name. ```swift public func guestLogin(_ firstName: String, lastName: String, success: @escaping() -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `firstName` | `String` | The guest's first name. | | `lastName` | `String` | The guest's last name. | | `success` | `Closure` | Called when sign-in succeeds. | | `failure` | `Closure` | Called when sign-in fails, with the error. | #### Example usage ```swift AuthenticateService.shared.guestLogin(firstName, lastName: lastName, success: { // Guest login successful // Perform any actions or navigate to the next screen }, failure: { error in // Guest login failed // Handle the error or display an error message }) ``` ### Login by token (SSO) `loginBySSOToken` signs a user in with a single sign-on (SSO) token. See [SSO login](https://developers.vsee.com/guides/clinickit/sso-login) for the full flow. ```swift public func loginBySSOToken(_ token: String, success: @escaping() -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `token` | `String` | The single sign-on token. | | `success` | `Closure` | Called when sign-in succeeds. | | `failure` | `Closure` | Called when sign-in fails, with the error. | #### Example usage ```swift // Sign in with the provided SSO token AuthenticateService.shared.loginBySSOToken(ssoToken, success: { // Authentication successful // Perform any actions or navigate to the next screen }, failure: { error in // Authentication failed // Handle the error or display an error message }) ``` ### Logout `logoutVC` ends the VSee Clinic session. ```swift public func logoutVC(success: @escaping() -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `success` | `Closure` | Called when logout succeeds. | | `failure` | `Closure` | Called when logout fails, with the error. | #### Example usage ```swift AuthenticateService.shared.logoutVC(success: { // Logout successful // Perform actions after successful logout }) { error in // Logout failed // Handle the error or display an error message } ``` ### Restore a signed-in session `restoreLoginSession` restores the previous user's session. ```swift public func restoreLoginSession(success: @escaping() -> Void, failure: @escaping (Error) -> Void) ``` | Parameter | Type | Description | | --- | --- | --- | | `success` | `Closure` | Called when the session is restored. | | `failure` | `Closure` | Called when the session can't be restored, with the error. | #### Example usage ```swift // Restore the session of the previously signed-in user AuthenticateService.shared.restoreLoginSession(success: { // Session restored // Perform any necessary actions or navigate to the next screen }, failure: { error in // Failed to restore the session // Handle the error or display an error message }) ```