Back

createPhoneSession executed with current userId throws "Server Error"

  • 0
  • Accounts
  • Cloud
kstulgys
11 Jun, 2023, 19:16

I'm using appwrite cloud. In my app I'm logged in with google provider. When I execute createPhoneSession providing current session userId it throws "Server Error"

TL;DR
TL;DR: User is trying to use the createPhoneSession function with the current session's userId, but it is resulting in a "Server Error" message. The solution suggested is to use the Appwrite functions and server SDK, along with an API key. Additionally, the user can update the phone number without a password using the server-side SDK. The suggested flow for updating the phone number is: updatePhone, createPhoneVerification, and updatePhoneVerification. The user's specific use case involves logging in with Google and then verifying with a phone number. Further clarification is needed on the user's project ID and if they are trying to
Drake
11 Jun, 2023, 19:17

What's your project id?

Binyamin
11 Jun, 2023, 19:17

Are you trying to create createPhoneSession while the user is logged in?

kstulgys
11 Jun, 2023, 19:17

647de70a6139cddef6d2

kstulgys
11 Jun, 2023, 19:17

yes

Binyamin
11 Jun, 2023, 19:18

The function is intended to be used to login the user.

Binyamin
11 Jun, 2023, 19:18

Can you elaborate about your use case?

kstulgys
11 Jun, 2023, 19:18

My use case is that I need to log in user with google and then verify with phone

Binyamin
11 Jun, 2023, 19:19
Drake
11 Jun, 2023, 19:19

(after calling update phone to set the phone number)

kstulgys
11 Jun, 2023, 19:21

account.updatePhone(phone, password); what is password?

Binyamin
11 Jun, 2023, 19:21

With this endpoint you can update the user phone number.

Binyamin
11 Jun, 2023, 19:22

So the flow will be

  1. updatePhone
  2. createPhoneVerification
  3. updatePhoneVerification
Binyamin
11 Jun, 2023, 19:22

You can also add the phone number without a password using a Server side SDK https://appwrite.io/docs/server/users?sdk=nodejs-default#usersUpdatePhone

Drake
11 Jun, 2023, 19:23

Since the user was created with oauth, they may need to go through the reset password flow to set their password...we plan on changing this in 1.4 such that you wouldn't need to pass a password

Drake
11 Jun, 2023, 19:24

Appwrite function and server SDK might be a good approach to update the phone without requiring password

kstulgys
11 Jun, 2023, 19:25

client .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ;

what is that secret API key ?

Binyamin
11 Jun, 2023, 19:31

To use the Server side SDK You should use Appwrite functions for that https://appwrite.io/docs/functions

Inside Appwrite function you get higher level of access with an API key https://appwrite.io/docs/keys

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