Auth0 React Native SDK Throws Connection Does Not Exist Error During Passwordless Authentication

Overview

An error occurs during Passwordless Short Message Service (SMS) or Email authentication using the Auth0 React Native SDK because the application invokes the database passwordless challenge methods instead of the core authentication orchestrator methods. Resolve this issue by using the orchestration methods under the auth0.auth namespace. The following error generates during authentication:

 

PASSWORDLESS_CHALLENGE_FAILED: The specified connection does not exist or is not a database connection

 

Applies To

  • Auth0
  • React Native Software Development Kit (SDK)
  • Passwordless SMS Authentication
  • Passwordless Email Authentication

Cause

Auth0 specifically designs the auth0.passwordless.* methods, such as challengeWithPhoneNumber() and challengeWithEmail(), for One-Time Password (OTP) authentication on Database Connections. Passing connection: "sms" or connection: "email" to these methods causes validation to fail because native Passwordless SMS and Email connections are distinct Passwordless strategies, not Auth0 Database Connections.

Solution

How is the connection error resolved?

For standard Passwordless SMS and Email connections, use the orchestration methods under auth0.auth rather than the auth0.passwordless database interface. Review the following table to identify the correct method for the desired action.

 

Strategy
Desired Action
Incorrect Method (Database OTP)
Correct Method (Passwordless Connection)
SMS
Request OTP
passwordless.challengeWithPhoneNumber()
auth.passwordlessWithSMS()
SMS
Verify OTP
passwordless.loginWithOTP()
auth.loginWithSMS()
Email
Request OTP
passwordless.challengeWithEmail()
auth.passwordlessWithEmail()
Email
Verify OTP
passwordless.loginWithOTP()
auth.loginWithEmail()

Implement the Passwordless SMS flow.

Request the SMS code and verify the received SMS code by executing the following code snippets.

Update the implementation to use passwordlessWithSMS to instruct the Auth0 SMS connection to send a one-time code.

await auth0.auth.passwordlessWithSMS({ 
  phoneNumber: '+11234567890', 
  connection: 'sms', 
  send: 'code' 
});

Capture the input and verify the code using loginWithSMS.

const credentials = await auth0.auth.loginWithSMS({ 
  phoneNumber: '+11234567890', 
  code: '<otp_code>' 
});

Implement the Passwordless Email flow.

Request the Email code and verify the received Email code by executing the following code snippets.

Update the implementation to use passwordlessWithEmail to instruct the Auth0 SMS connection to send a one-time code.

await auth0.auth.passwordlessWithEmail({ 
  email: 'user@example.com', 
  connection: 'email', 
  send: 'code' 
});

Capture the input and verify the code using loginWithEmail.

const credentials = await auth0.auth.loginWithEmail({ 
  email: 'user@example.com', 
  code: '<otp_code>' 
});
 

Recommended content

No recommended content found...