Back

Failed creating JWT via REST

  • 0
  • Auth
  • Web
  • Cloud
  • REST API
Felipe Amaral
4 Feb, 2025, 20:17

The endpoint v1/account/jwts aint working as REST documentation says. It only works using Cookies recived from v1/account/sessions/email. My test commands steps are:

1st. Create Session

TypeScript
curl -sX POST "https://appwrite.mydomain.io/v1/account/sessions/email" \
     -H "Content-Type: application/json" \
     -H "X-Appwrite-Response-Format: 1.6.0" \
     -H "X-Appwrite-Project: project-id" \
     -d '{"email": "user@email.com", "password": "1234347"}' \
     -c cookie.txt

2nd. Create JWT

TypeScript
curl -sX POST "https://appwrite.mydomain.io/v1/account/jwts" \
     -H "Content-Type: application/json" \
     -H "X-Appwrite-Project: project-id" \
     -b cookie.txt

This works fine. But, i would like to know if i can make this request without cookies, usgin sessionID and UserID from JSON provided from v1/account/sessions/email request. When I try any other way i get this error:

TypeScript
{
  "message": "User (role: guests) missing scope (account)",
  "code": 401,
  "type": "general_unauthorized_scope",
  "version": "1.6.0"
}
TL;DR
Issue: Unable to create JWT via REST without using cookies, using `sessionID` and `UserID` instead results in error code 401. Solution: The endpoint `v1/account/jwts` requires the `account` scope which is missing when not using cookies. Stick to using cookies as the provided method.
Felipe Amaral
4 Feb, 2025, 20:31
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