Back

[SOLVED] 1.4 Function JWT token

  • 0
  • Functions
  • Cloud
whataboutno13
22 Sep, 2023, 10:25

Hi there,

I am upgrading my cloud functions from 1.1.2 to 1.4.3. In the "old" functions one could use the function variables like APPWRITE_FUNCTION_JWT or APPWRITE_FUNCTION_USER_ID. Do these, now environment variables, still exist or do I need to pass those information's myself?

TL;DR
In version 1.4.3 of Appwrite cloud functions, environment variables like `APPWRITE_FUNCTION_JWT` or `APPWRITE_FUNCTION_USER_ID` have been moved to headers. You can now access them using `context.req.headers['x-appwrite-user-id']` and `context.req.headers['x-appwrite-user-jwt']`.
Meldiron
22 Sep, 2023, 10:27

Hey there πŸ‘‹ Information that used to be in env variables and is not static was moved to headers. For example, function ID stayed as env var, as that never changes. But user ID and JWT are different with every request, so those are now headers. Here you can check all that Appwrite provides for you: https://appwrite.io/docs/functions-develop#headers

In your scenario you are looking for context.req.headers['x-appwrite-user-id'] and context.req.headers['x-appwrite-user-jwt'].

whataboutno13
22 Sep, 2023, 10:34

Yes! Thats what I was looking for, thank you! <:appwriteheart2:1073243188954935387>

Meldiron
22 Sep, 2023, 10:34

<:appwriteheart2:946074073627246692>

Drake
22 Sep, 2023, 14:07

[SOLVED] 1.4 Function JWT token

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