Back

[SOLVED] Get session jwt token

  • 0
  • Users
  • Accounts
  • Web
Hexi
30 May, 2023, 12:39

rn its all in nextjs

TL;DR
The support thread discusses getting a session JWT token. The thread is marked as solved, but the solution is not mentioned. However, there is a tip provided on how to get the user who triggered the session. The user also expresses issues with running functions from the client and mentions using Next.js.
D5
30 May, 2023, 12:43

My suggestion is using functions. They're really easy to start with and basically you can trigger/call them from your app, so you could achieve what you're trying really easily, and even send an email or notification through it, if needed.

I don't have experience with JWT, so I can't give you too much guidance on that. Sorry for not being able to solve your main issue ๐Ÿ™

Hexi
30 May, 2023, 12:47

With functions you can easily get the user?

Hexi
30 May, 2023, 12:47

and it can be called by a user

D5
30 May, 2023, 12:47

Yeah

Hexi
30 May, 2023, 12:47

hmm

D5
30 May, 2023, 12:47

Yes, too

Hexi
30 May, 2023, 12:47

That sounds pretty nice ๐Ÿ™‚

Hexi
30 May, 2023, 13:17

Cant find how to run them from the client in the docs

Hexi
30 May, 2023, 13:18

copilot came up with this

Hexi
30 May, 2023, 13:18

but I dont think it works

D5
30 May, 2023, 13:19

It's

TypeScript
const promise = functions.createExecution('[FUNCTION_ID]');
D5
30 May, 2023, 13:19

Not function name

Hexi
30 May, 2023, 13:20

Thanks

D5
30 May, 2023, 13:20

If you want to send it payload (for example, in a form, the fields) that's how it should be: It's

TypeScript
const promise = functions.createExecution('[FUNCTION_ID], [YOUR_PAYLOAD_HERE]');
D5
30 May, 2023, 13:21

By default, the server gets the current user who is executing the function, so you don't need to send anything related in the payload

D5
30 May, 2023, 13:23

To get the user who triggered the user, you can get it this way:

TypeScript
const userID = req.variables.APPWRITE_FUNCTION_USER_ID;
Hexi
30 May, 2023, 13:24

<a:happi:1107928866477064202>

D5
30 May, 2023, 13:25

Congrats on deploying and triggering your first function <:appwriterocket:823996226894692403>

joeyouss
30 May, 2023, 15:19

Congrats!!

joeyouss
30 May, 2023, 15:19

the best feeling tbh.

D5
30 May, 2023, 15:19

Yeah, I got several errors first time I tried ๐Ÿ˜†

joeyouss
30 May, 2023, 15:19

+1

joeyouss
30 May, 2023, 15:20

Gonna close this thread for now, if you have more questions, feel free to open a new post and find us in #๐Ÿš‘โ”‚support โค๏ธ thanks @D5

joeyouss
30 May, 2023, 15:20

[SOLVED] Get session 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