Android Customer User APIs
Customer user APIs for managed authentication, registration, recovery, user info, auth state and feature flags.
All APIs are accessed via Vipaso.user.customer
.
Login
Once a user has an account, logging in is straightforward. You pass the phone number or email as the identifier along with a password. The SDK will store the session token securely, and the auth state collectors will be notified of the change.
// Request: Login with email/phone and password
val loginRequest = LoginRequest(
userIdentifer = "user@example.com", // Can be email or phone number
password = "secure_password"
)
Vipaso.user.customer.login(loginRequest)
Logout
Remove the stored session token and notify collectors of the auth state change.
Vipaso.user.customer.logout()
Authentication State
Observe whether a user is currently authenticated.
Vipaso.user.customer.isAuthenticated()
.collect { authenticated ->
if (authenticated) {
// User is logged in, proceed with app functionality
} else {
// User is not logged in, show login screen
}
}
Fetch User
Get current user information.
val user: CustomerUser = Vipaso.user.customer.fetchUser()
Registration
Registration consists of three steps, each requiring a network call.
Start Signup Flow
// Begin user registration with phone number
val signupRequest = StartSignupRequest(phoneNumber = "+1234567890")
val signupResponse: StartSignupResponse = Vipaso.user.customer.startSignupFlow(signupRequest)
Verify Signup OTP
// Verify phone number during signup using OTP
val verifyRequest = VerifyPhoneNumberRequest(
flowId = signupResponse.flowId,
otp = "123456"
)
val verifyResponse: VerifyPhoneNumberResponse = Vipaso.user.customer.verifyPhoneNumber(verifyRequest)
Finalize Signup Flow
val finishRequest = FinishSignupRequest(
flowId = verifyResponse.flowId,
password = "secure_password",
email = "user@example.com",
// name is deprecated; use firstName and lastName instead
firstName = "John",
lastName = "Doe",
phoneNumber = "+1234567890"
)
val signupResult: FinishSignupResponse = Vipaso.user.customer.finalizeSignupFlow(finishRequest)
Account Recovery
Password recovery consists of three steps, each requiring a network call.
Start Recovery Flow
val recoveryRequest = StartRecoveryRequest(phoneNumber = "+1234567890")
val recoveryResponse: StartRecoveryResponse = Vipaso.user.customer.startRecoveryFlow(recoveryRequest)
Verify Recovery OTP
val recoveryOtpResponse: RecoveryOtpResponse = Vipaso.user.customer.verifyRecoveryOtp(
flowId = recoveryResponse.flowId,
otpCode = "123456"
)
Finalize Recovery Flow
val passwordRequest = UpdatePasswordRequest(
settingFlowId = "settings-flow-abc",
sessionToken = "session-token-xyz",
password = "new_secure_password"
)
Vipaso.user.customer.finalizeRecoveryFlow(passwordRequest)
Feature Flags
Fetch feature flags relevant for the Customer app.
val featureFlags: Set<VipasoFeatureFlagWithState> = Vipaso.user.customer.fetchFeatureFlags()