Back

JWT fails with error: Failed to verify JWT. Invalid token: Incomplete segments

  • 0
  • Self Hosted
  • Accounts
  • Web
HoXsan
29 Aug, 2023, 03:40

So I am trying to setup SSR authentication on my Nextjs project. The flow is:

  • Authenticate using OAuth
  • Get secret key from /auth/oauth2/success and 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

TL;DR
The user is trying to set up SSR authentication on a Next.js project using OAuth. They are encountering an error message that says "Failed to verify JWT. Invalid token: Incomplete segments." One suggestion from another user is to set the header "X-Fallback-Cookies" in the Appwrite client. Additionally, it is recommended to use the Appwrite SDK for the server-side client and the SDK for Node.js for implementing the API key. The user should also note that a session cookie is not the same as a JWT and they cannot be used interchangeably. No solution is provided in the thread for the specific error message mentioned.
Drake
29 Aug, 2023, 04:13

Yes because the session cookie is not the same thing as a JWT. You can't use them interchangeably

otik
30 Aug, 2023, 16:57

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

otik
30 Aug, 2023, 16:58

only think you have to do is to set header into appwrite client "X-Fallback-Cookies"

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