How to create a custom JWT for authentication #18273
-
|
We're migrating from Firebase to Supabase and are having difficulties around custom JWT for authentication. We're not using Supabase Auth. In firebase this was pretty straight forward: from the backend we call the Go With supabase I've not been able to find the equivalent, only examples when using Auth, which we're not. We've tried creating a JWT manually with the following claims and signed using HS256 with the JWT Secret from supabase: With no luck. Has anyone done something similar? Is there another way to achieve this? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Are you using the jwt in the Authorization header and the normal anon key in the apikey header? What does no luck mean? |
Beta Was this translation helpful? Give feedback.

You should respond to the comments rather than start a new one.
Your custom jwt has to go in the authenticated header, not the apikey. The apikey should be the anon one. If supabase_jwt is your custom jwt that is not the place to put it.
https://supabase.com/docs/reference/javascript/initializing?example=with-additional-parameters
You add Authorization header with the header option. The Authorization header needs to be
Bearer my_custom_jwt.Also from my first link above: