JWT fails with error: Failed to verify JWT. Invalid token: Incomplete segments
- 0
- Self Hosted
- Accounts
- Web
So I am trying to setup SSR authentication on my Nextjs project. The flow is:
- Authenticate using OAuth
- Get secret key from
/auth/oauth2/successand save as cookie
On page request:
- Get cookie (secret key)
- Set jwt using
client.setJWT(secretkey) - Get current user using
account.get()
Then I get this error: Failed to verify JWT. Invalid token: Incomplete segments
Yes because the session cookie is not the same thing as a JWT. You can't use them interchangeably
Basicly i think (my oppinion) that best way is to use appwrite sdk for client on server side. And when you want to implement your api key you just will have to use sdk for node.js
only think you have to do is to set header into appwrite client "X-Fallback-Cookies"
Recommended threads
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Failed to create function
Hey everyone 👋 I'm having an issue creating Functions on Appwrite Cloud and I'm not sure if it's a platform bug or something wrong in my project. When I try t...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...