Back

[SOLVED] Validate JWT in cloud functions

  • 0
  • Functions
  • Accounts
  • Cloud
sswastik02
27 Nov, 2023, 09:37

I am creating a function that will validate the jwt that comes in the headers(x-appwrite-user-jwt), and then perform some db operation.

I am using node-18 to write the cloud functions, I am thinking of using jsonwebtoken to validate the JWT, but I can't seem to find the SECRET of the JWT that appwrite uses to sign.

How do I set SECRET for the appwrite to use in JWT.

TL;DR
The user is looking for a way to validate a JWT in cloud functions using Node.js 8. They are considering using the 'jsonwebtoken' package, but they can't find the secret key that Appwrite uses to sign the JWT. The solution is to set the secret key for Appwrite to use in the JWT.
Drake
27 Nov, 2023, 16:23

the best way to validate the JWT token is to do:

TypeScript
client.setJWT(token);
const account = new Account(client);
let isValid = false;
try {
  const user = account.get();
  isValid = true;
catch (e) {
  context.log(e.toString());
}
sswastik02
27 Nov, 2023, 19:08

Great, Thank you so much.

sswastik02
27 Nov, 2023, 19:08

[SOLVED ]Validate JWT in cloud functions

Drake
27 Nov, 2023, 19:08

[SOLVED] Validate JWT in cloud functions

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