#Get JWT from WorkOS

3 messages · Page 1 of 1 (latest)

near aurora
#

I have two pages. One is a AstroJS page with a callback endpoint at /api/auth/callback.ts, and the other is a background script running on chrome extension chrome-extension://iiklfmkehcjmafegbjpiahianphhacml.

How would I set up these two pages to save the JWT in cookies when a user logged into a WorkOS page? It might require sending a message to the chrome extension with the JWT.

polar spokeBOT
#

Hi @near aurora. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain specific information about setting up JWT with WorkOS or handling authentication in a Chrome extension using Astro.

However, I can provide some general guidance based on the information available. In Astro, you can use the Astro.cookies.set() method to save cookies, which could potentially be used to store a JWT. Here's an example of how you might set a cookie:

Astro.cookies.set("userToken", user.token, { expires, path });

This code sets a cookie named userToken with the value of user.token. The expires variable determines when the cookie will expire, and path sets the URL path that must exist in the requested URL in order to send the Cookie header.

Remember that Astro.cookies only works in Astro pages (i.e., Astro files inside the /pages directory). Also, if you're running Astro in a serverless environment, cookies need to be included in each request.

For more specific guidance on your use case, you might find the Astro documentation (https://docs.astro.build/) helpful.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: