
This is my code:
const client = new Client()
.setEndpoint(endpoint)
.setProject(projectId)
.setKey(apiKey);
const account = new Account(client);
const token = await account.createPhoneToken(ID.unique(), '+999999999');
console.log(token);
const session = await account.createSession(token.userId, token.secret);
console.log(session);
and i keep getting this error, which means the token passed is wrong. but this is the output i am getting from token:
{
'$id': '67790ca497ccd684a12e',
'$createdAt': '2025-01-04T10:25:40.622+00:00',
userId: '67790a6f000cd0c04e96',
secret: 'eyJpZCI6IjY3NzkwYTZmMDAwY2QwYzA0ZTk2Iiwic2VjcmV0IjoiMDAwMDAwIn0=',
expire: '2025-01-04T10:40:40.621+00:00',
phrase: ''
}

I don't think it's supposed to be token.secret
in createSession
. It's supposed to be the SMS Code.
Ref - https://x.com/appwrite/status/1834545614811472026

also, why Server SDK here with Key?

to get secret, otherwise it would be blank

and shouldnt user be able to signin without the sms code, and being unverified

that worked! thanks

i got confused between token secret and sms secret i guess 😅

[SOLVED] Invalid token passed in the request.
Recommended threads
- User Authentication through REST API
Hey everyone, I’m looking for some guidance on the best way to authenticate frontend requests to my API gateway using Appwrite sessions. Right now, I'm trying ...
- Custom domain issue
Hello following another post I'm creating dedicated post according to my project ID: 67ffbd800010958ae104 I deployed for debug my React Native app in web, chrom...
- Appwrite DNS Record Invalid on 123reg
So I go to the project settings and add in my domain name. Then when I add the CNAME record to 123reg it says that ''Record data is invalid'' As seen in the s...
