Authentication flows
Use Auth for sign-in and sign-up flows, and to manage sessions. You can access auth with Clerk.auth.
Sign in
Sign in with password
Sign in directly with an identifier (email, phone, or username) and password:
val signIn = Clerk.auth.signInWithPassword {
identifier = "user@email.com"
password = "secretpassword"
}Sign in with OTP (email)
Send an to the supplied email, and then verify the code.
var signIn = Clerk.auth.signInWithOtp { email = "user@email.com" }
signIn = signIn.verifyCode("123456")Sign in with OTP (phone)
Send an to the supplied phone number, and then verify the code.
var signIn = Clerk.auth.signInWithOtp { phone = "+1234567890" }
signIn = signIn.verifyCode("123456")Sign in with OAuth
Sign in using an OAuth provider (e.g., Google, GitHub):
val result = Clerk.auth.signInWithOAuth(OAuthProvider.GOOGLE)Sign in with ID token
Sign in with an ID token from a provider:
val result = Clerk.auth.signInWithIdToken {
token = idToken
provider = IdTokenProvider.GOOGLE
}Sign in with passkey
Sign in using a passkey:
val signIn = Clerk.auth.signInWithPasskey()Sign in with Enterprise SSO
Sign in using Enterprise SSO:
val result = Clerk.auth.signInWithEnterpriseSso { email = "user@company.com" }Sign in with ticket
Sign in using a ticket generated from the Backend API:
val signIn = Clerk.auth.signInWithTicket(ticket)Sign in with identifier
Start a sign-in with an identifier (email, phone, or username):
// Email
var signIn = Clerk.auth.signIn { email = "user@email.com" }// Phone
var signIn = Clerk.auth.signIn { phone = "+1234567890" }// Username
var signIn = Clerk.auth.signIn { username = "johndoe" }Continue an existing sign-in
Use these methods when you already have a SignIn from Clerk.auth.signIn { ... } and want to complete it with a specific factor or provider.
Send and verify email code
Send the user an via email to verify their sign-in. Then verify the code that the user supplies:
signIn = signIn.sendEmailCode()
signIn = signIn.verifyCode("123456")Send and verify phone code
Send the user an via SMS to verify their sign-in. Then verify the code that the user supplies:
signIn = signIn.sendPhoneCode()
signIn = signIn.verifyCode("123456")signIn = signIn.verifyWithPassword("secretpassword")signIn = signIn.verifyWithPasskey(credential)Multi-factor authentication
After completing first factor verification, if multi-factor authentication (MFA) is required, use these methods to complete the second factor verification. The examples assume you already have a SignIn from a sign-in flow.
MFA with phone code
Send and verify an MFA code via SMS:
signIn = signIn.sendMfaPhoneCode()
signIn = signIn.verifyMfaCode("123456", MfaType.PHONE_CODE)MFA with email code
Send and verify an MFA code via email:
signIn = signIn.sendMfaEmailCode()
signIn = signIn.verifyMfaCode("123456", MfaType.EMAIL_CODE)MFA with TOTP (authenticator app)
Verify using a TOTP code from an authenticator app:
signIn = signIn.verifyMfaCode("123456", MfaType.TOTP)MFA with backup code
Verify using a backup code:
signIn = signIn.verifyMfaCode("backup123", MfaType.BACKUP_CODE)Password reset
The Clerk Android SDK provides methods to reset user passwords via email or phone verification.
Password reset with email
Reset password using email verification:
var signIn = Clerk.auth.signIn { email = "user@email.com" }
signIn = signIn.sendResetPasswordCode { email = "user@email.com" }
signIn = signIn.verifyCode("123456")
signIn = signIn.resetPassword(newPassword = "newpassword", signOutOfOtherSessions = true)Password reset with phone
Reset password using phone verification:
var signIn = Clerk.auth.signIn { phone = "+1234567890" }
signIn = signIn.sendResetPasswordCode { phone = "+1234567890" }
signIn = signIn.verifyCode("123456")
signIn = signIn.resetPassword(newPassword = "newpassword", signOutOfOtherSessions = true)val signUp = Clerk.auth.signUp {
email = "newuser@email.com"
phone = "+1234567890"
password = "secretpassword"
firstName = "John"
lastName = "Doe"
username = "johndoe"
legalAccepted = true
}Update a sign-up
Update sign-up information:
signUp = signUp.update {
email = "newuser@email.com"
phone = "+1234567890"
password = "secretpassword"
firstName = "John"
lastName = "Doe"
username = "johndoe"
legalAccepted = true
}Sign up with OAuth
Sign up using OAuth (e.g., Google, GitHub):
val result = Clerk.auth.signUpWithOAuth(OAuthProvider.GOOGLE)Sign up with ID token
Sign up using an ID token:
val result = Clerk.auth.signUpWithIdToken(idToken, IdTokenProvider.GOOGLE) {
firstName = "John"
lastName = "Doe"
}Sign up with Enterprise SSO
Sign up using Enterprise SSO:
val result = Clerk.auth.signUpWithEnterpriseSso { email = "user@company.com" }Sign up with ticket
Sign up using a ticket generated from the Backend API:
val signUp = Clerk.auth.signUpWithTicket(ticket)Continue an existing sign-up
Use these methods when you already have a SignUp from Clerk.auth.signUp { ... } and want to complete it with a specific factor or provider.
Send and verify email via OTP
Send the user an via email to verify their account. Then verify the code that the user supplies:
signUp = signUp.sendEmailCode()
signUp = signUp.verifyCode("123456", VerificationType.EMAIL)Send and verify phone via OTP
Send the user an via SMS to verify their account. Then verify the code that the user supplies:
signUp = signUp.sendPhoneCode()
signUp = signUp.verifyCode("654321", VerificationType.PHONE)Current sign-in/sign-up
Access the in-progress sign-in or sign-up stored on the client for multi-step flows.
Current sign-in
val currentSignIn = Clerk.auth.currentSignInval currentSignUp = Clerk.auth.currentSignUpSession management
The Clerk Android SDK provides methods to manage user sessions, including signing out, switching sessions, and revoking sessions.
Sessions
Retrieve all sessions for the current client:
val sessions = Clerk.client.sessionsGet session token
Retrieve the user's session token:
val token = Clerk.auth.getToken()
// or with options
val token = Clerk.auth.getToken(GetTokenOptions(template = "my-template"))Set current session
Set the current session and optionally the :
Clerk.auth.setActive(sessionId = sessionId, organizationId = organizationId)Revoke session
Revoke a specific session:
Clerk.auth.revokeSession(session)Sign out
Sign out the current user:
// Sign out from the current session
Clerk.auth.signOut()
// Sign out from a specific session
Clerk.auth.signOut(sessionId = sessionId)Deep linking
Handle OAuth/SSO deep link callbacks in your Activity:
// In your Activity's onCreate or onNewIntent
Clerk.auth.handle(intent.data)Feedback
Last updated on
Edit on GitHub