Verifying JWT signing key with jsonwebtoken
I want to switch to the new JWT signing keys and I can't get it to work with
"jsonwebtoken": "^9.0.2",
Using the the Legacy JWT Secret, this worked:
where supabaseJwtSecret
was just the Legacy JWT secret key.
I tried changing the algorithm like this:
jwt.verify(token, supabaseJwtSecret || "", { algorithms: ['ES256'] })
But I get Token verification error: secretOrPublicKey must be an asymmetric key when using ES256
.
I am using the new format : sb_publishable_
Has anyone made verifying the new keys work with jasonwebtoken?4 Replies
Thanks a lot @inder , I'll try that. I guess the
const token
is still the same user's JWT that would be send via the header to the server, correct?
in the old format like this Authorization: Bearer <eyJhbGciOiJFUzI1NiIsImtpZCI6IjY0ZmJjYWE5...>
Yes correct, when you make a request using supabase sdk for example to invoke a function, the token will be added in authorization header.
Just remember that the new publishable and secret keys (no user session to replace apikey in authorization header) won't work like they used to if not going thru the Supabase infra. The edge functions are an example where they have a dislaimer about this.