Back

Update phone verification error

  • 0
  • Android
  • Flutter
  • Accounts
  • Cloud
_lk_7t2_
19 Jun, 2023, 14:21

I'm trying the to set up phone verification with flutter android app When using the createPhoneSession() method everything goes well ( the phone receives the 6 digits code )

But when verifying using updatePhoneVerification() method this error is thrown Unhandled Exception: AppwriteException: user_invalid_token, Invalid token passed in the request. (401)

I do not understand because I passed the right userId and the right secret so what is the token mentinoned in the exception is related to ?

Thanks

TL;DR
User is experiencing an error when trying to verify phone number using the `updatePhoneVerification()` method. The error states "Invalid token passed in the request (401)". User is unsure about the token mentioned in the error message. Solution provided by another user is to use the `updatePhoneSession()` method instead of `updatePhoneVerification()` to complete the `createPhoneSession` flow. Code example is provided.
Deleted User
19 Jun, 2023, 14:22

Can you share the code?

Deleted User
19 Jun, 2023, 14:22

For the updatePhoneVerification function?

_lk_7t2_
19 Jun, 2023, 14:25

final r = await ref.read(appwriteAccountProvider).updatePhoneVerification( userId: userId, secret: secret, );

Deleted User
19 Jun, 2023, 14:28

My bad, in order to complete the createPhoneSession flow you'll need to use updatePhoneSession and not the updatePhoneVerification

Like so:

TypeScript
final r = await ref.read(appwriteAccountProvider).updatePhoneSession(
          userId: userId,
          secret: secret,
        );
_lk_7t2_
19 Jun, 2023, 14:30

You wrote updatePhoneVerification() twice

Deleted User
19 Jun, 2023, 14:30

Fixed

Deleted User
19 Jun, 2023, 14:30

Thanks

_lk_7t2_
19 Jun, 2023, 14:31

Ok I'm going to test it

_lk_7t2_
19 Jun, 2023, 14:34

It works thanks

_lk_7t2_
19 Jun, 2023, 14:35

But there is a way to register like tests number ? To avoid sending messages during development stage

Deleted User
19 Jun, 2023, 14:40

Good!

Deleted User
19 Jun, 2023, 14:40

I don't think so, nope

_lk_7t2_
19 Jun, 2023, 14:42

πŸ₯Ή no problem I'll try to set all things up before going beyond the limits

Deleted User
19 Jun, 2023, 14:43

<:appwriteupvote:899677724615016528>

joeyouss
20 Jun, 2023, 13:14

ah no, you can try using functions for that though and make testing folders different than your production folders

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