Back

[CLOSED] Failed to verify JWT

  • 0
  • Databases
  • Web
djcali
16 Aug, 2023, 04:55

I get logged in server side and no problem setting the cookie.

When i try to use it to create a document using REST:

TypeScript
         const response = await fetch(`${AppwriteEndpoint}/databases/${Database.name}/collections/${Collection.test}/documents`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'X-Appwrite-Response-Format': '1.0.0',
                    'X-Appwrite-Project': AppwriteProject,
                    'X-Appwrite-JWT': jwtVal
                },
                body: JSON.stringify(body)

            });

I get a invalid token as a response. I console logged the token jwtValand it matches what is in the cookie. not sure what the problem is.

TypeScript
{
  message: 'Failed to verify JWT. Invalid token: Incomplete segments',
  code: 401,
  type: 'user_jwt_invalid',
  version: '1.3.8'
}
TL;DR
The user is encountering an issue where they are trying to use a JWT token to create a document using REST but it is returning an 'invalid token' error. The user has already confirmed that the token matches what is in the cookie. No solution is provided in the thread.
Drake
16 Aug, 2023, 05:36

A JWT is not a cookie. You can't use them interchangeably

djcali
16 Aug, 2023, 05:40

oh ok.

joeyouss
16 Aug, 2023, 13:52

[CLOSED] Failed to verify JWT

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