Skip to content
Back

Problem with phone sms auth

  • 0
  • Auth
  • Web
  • Cloud
mcjo3324
1 Nov, 2024, 13:39

Hello,

Actually i don't receive any code on my phone.

I'm using the phone auth by SMS, i don't have any errors, i used differents phone numbers but i don't have the code : is there some problems with the server or whatever ?

Thanks.

TL;DR
Developers experiencing issues with phone SMS authentication. Code provided for creating phone tokens and checking user existence. No recent changes made. Users not receiving SMS codes despite trying different phone numbers. Solution: - Check server status and SMS service provider. - Verify if SMS permissions are correctly set up in the server. - Ensure phone number format is correct and matches the expectations of the SMS service. - Debug code for any potential issues causing SMS not to be sent.
Steven
1 Nov, 2024, 13:40

Are you using Appwrite cloud? What's your code?

mcjo3324
1 Nov, 2024, 13:41

Yep but yesterday everything working but today it's not and i don't change anything in my code

mcjo3324
1 Nov, 2024, 13:42

My code :

TypeScript
try {
    const users = new Users(args.client);
    const account = new Account(args.client);
    const phoneNumber = args.reqBody.phone.trim();
    const result = await users.list([Query.equal("phone", phoneNumber)]);

    // If user exist create phone token and return to the client that user exist so it can redirect to the OTP client view.
    if (result.users.length) {
      await account.createPhoneToken(result.users[0].$id, phoneNumber);
      return args.res.json(
        { userExist: true, userId: result.users[0].$id },
        200,
        args.CORSHeadersResponse,
      );
    }

    // User does not exist do not send SMS and indicate to the client to redirect to the personal informations view.
    return args.res.json({ userExist: false }, 200, args.CORSHeadersResponse);
  } catch (err) {
    return args.res.json({ error: err.message }, 500, args.CORSHeadersResponse);
  }
Steven
1 Nov, 2024, 13:43

Please DM me the phone number and the exact timestamp you last tried the phone auth

Steven
1 Nov, 2024, 13:43

And your project id

mcjo3324
1 Nov, 2024, 13:43

Yes, i'm going to send you all the informations, thanks

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