Back

Creating Appwrite Session with Phone Number Authentication - Custom OTP Flow

  • 0
  • Flutter
  • Auth
saadi ahmed <ahmed>
21 Nov, 2024, 10:01

Context: I'm implementing a custom phone number authentication flow using a third-party OTP service. I'm trying to create a session in Appwrite, but encountering an user_invalid_token error.

Current Implementation:

try { final token = await account.createPhoneToken( userId: ID.unique(), phone: phone ); final id = token.userId;

// Generating custom OTP generatedOTP = generateOTP();

// Attempting to create session await account.createSession(userId: id, secret: generatedOTP); } catch (e) { print('Error creating user: $e'); }

Additional Details:

-Using Flutter -Using a third-party OTP generation service -Getting ** AppwriteException: user_invalid_token, Invalid token passed in the request. (401)**

TL;DR
Developers creating a custom phone number authentication flow in Appwrite are encountering an 'user_invalid_token' error when trying to create a session. The error arises due to passing an incorrect token in the request. Double-check the authentication token being used and ensure it is generated and passed correctly for session creation.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more