First factor
These are all methods on the SignIn
class that allow you to handle the first factor of a multi-factor authentication flow.
prepareFirstFactor()
Begins the first factor verification process. This is a required step in order to complete a sign in, as users should be verified at least by one factor of authentication.
Common scenarios are one-time code (OTP) or social account (SSO) verification. This is determined by the accepted strategy
parameter values. Each authentication identifier supports different strategies.
- Name
strategy
- Type
string
- Description
The
strategy
value depends on the object'sidentifier
value. Each authentication identifier supports different verification strategies. Possiblestrategy
values are:email_link
: User will receive an email magic link via email. Theemail_address_id
parameter can also be specified to select one of the user's known email addresses.email_code
: User will receive a one-time authentication code via email. At least one email address should be on file for the user. Theemail_address_id
parameter can also be specified to select one of the user's known email addresses.phone_code
: User will receive a one-time authentication code in their phone, via SMS. At least one phone number should be on file for the user. Thephone_number_id
parameter can also be specified to select which of the user's known phone numbers the SMS will go to.web3_metamask_signature
: The verification will attempt to be completed using the user's Web3 wallet address via Metamask. Theweb3_wallet_id
parameter can also be specified to select which of the user's known Web3 wallets will be used.web3_coinbase_wallet_signature
: The verification will attempt to be completed using the user's Web3 wallet address via Coinbase Wallet. Theweb3_wallet_id
parameter can also be specified to select which of the user's known Web3 wallets will be used.oauth_<provider>
: The user will be authenticated with their social sign-in account. See available social providers.
- Name
emailAddressId?
- Type
string
- Description
Unique identifier for the user's email address that will receive an email message with the one-time authentication code. This parameter will work only when the
email_code
strategy is specified.
- Name
phoneNumberId?
- Type
string
- Description
Unique identifier for the user's phone number that will receive an SMS message with the one-time authentication code. This parameter will work only when the
phone_code
strategy is specified.
- Name
web3WalletId?
- Type
string
- Description
Unique identifier for the user's Web3 wallet address. This parameter will work only when the
web3_metamask_signature
orweb3_coinbase_wallet_signature
strategy is specified.
- Name
redirectUrl?
- Type
string
- Description
The URL that the OAuth provider should redirect to, on successful authorization on their part. This parameter is required only if you set the
strategy
param to an OAuth strategy likeoauth_<provider>
.
- Name
actionCompleteRedirectUrl?
- Type
string
- Description
The URL that the user will be redirected to, after successful authorization from the OAuth provider and Clerk sign in. This parameter is required only if you set the
strategy
param to an OAuth strategy likeoauth_<provider>
.
Returns
attemptFirstFactor()
Attempts to complete the first factor verification process. This is a required step in order to complete a sign in, as users should be verified at least by one factor of authentication.
Make sure that a SignIn
object already exists before you call this method, either by first calling SignIn.create
or SignIn.prepareFirstFactor
. The only strategy that does not require a verification to have already been prepared before attempting to complete it, is the password
strategy.
Depending on the strategy that was selected when the verification was prepared, the method parameters should be different.
- Name
strategy
- Type
string
- Description
The
strategy
value depends on the object'sidentifier
value. Each authentication identifier supports different verification strategies. Possiblestrategy
values are:'email_code'
: User will receive a one-time authentication code via email. At least one email address should be on file for the user.'phone_code'
: User will receive a one-time code via SMS. At least one phone number should be on file for the user.'password'
: The verification will attempt to be completed with the user's password.'web3_metamask_signature'
: The verification will attempt to be completed using the user's Web3 wallet address via Metamask.'web3_coinbase_wallet_signature'
: The verification will attempt to be completed using the user's Web3 wallet address via Coinbase Wallet.'passkey'
: The verification will attempt to be completed using the user's passkey.'reset_password_phone_code'
: Used when the user is trying to reset their password. The user will receive a one-time code via SMS.'reset_password_email_code'
: Used when the user is trying to reset their password. The user will receive a one-time code via email.
- Name
code?
- Type
string
- Description
The one-time code that was sent to the user as part of this verification step. This parameter is required only when
strategy
is set to'email_code'
,'phone_code'
,'reset_password_phone_code'
, or'reset_password_email_code'
.
- Name
password?
- Type
string
- Description
The user's password string. This parameter is required only when
strategy
is set topassword
.
- Name
signature?
- Type
string
- Description
Web3 wallet generated signature to be verified. This parameter is required only for Web3 verification strategies.
Feedback
Last updated on