You can log in and out with both customer and business users using the unified SDK.
Login
Customer Login
Customer users authenticate with their phone number and password:
let request = LoginRequest(identifier: phoneNumber, password: password)
vipaso.user.customer.login(request: request) { result in
switch result {
case .success:
// Success: authentication state change will be sent via VipasoDelegate
case .failure(let error):
// Error: handle login failure
print("Customer login failed: \(error.localizedDescription)")
}
}
Business Login
Business users authenticate with their email and password:
let request = LoginRequest(identifier: email, password: password)
vipaso.user.business.login(request: request) { result in
switch result {
case .success:
// Success: authentication state change will be sent via VipasoDelegate
case .failure(let error):
// Error: handle login failure
print("Business login failed: \(error.localizedDescription)")
}
}
If you debug your networking calls, you should see the following traffic:
- HTTP request and response for retrieving the flow id in the background:
GET /a/self-service/login/api HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"id": "b1f0d684-7c85-4efa-b8a6-6041e1e77eaa",
...
}
- HTTP request and response for logging in:
POST /a/self-service/login?flow=b1f0d684-7c85-4efa-b8a6-6041e1e77eaa HTTP/1.1
Content-Type: application/json
{
"identifier": "+439999999999",
"method": "password",
"password": "111111"
}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"session_token": "ory_st_ZXMeo8204gD0u3PbQu0DgsG3hBASzz8E",
"session": {
"id": "a29924fd-14d7-46ee-b329-73854e876405",
"identity": {
"id": "9a8cbfb3-87bd-4087-b48d-2569b1b43386",
...
},
...
},
...
}
Example screenshots from our development application:

Note: In the end the SDK will automatically generate and save a local key pair and send the public key to the backend. This needs to happen for the user to be considered logged in. You will see a PUT
request to /identity/pki/client/certificates
at the end of the flow.
Logout
Logout is synchronous and there is no backend communication involved. The SDK will clean up everything from its database and the keychain that are connected to the user.
Customer Logout
vipaso.user.customer.logout()
// Authentication state change will be sent via VipasoDelegate
Business Logout
vipaso.user.business.logout()
// Authentication state change will be sent via VipasoDelegate
Example screenshots from our development application:
