Skip to content

JWT is not valid when cheking on jwt.io #1039

Answered by iaincollins
jvorcak asked this question in Help
Discussion options

You must be logged in to vote

Hi there!

This fails because the JWT_SECRET is used to generate a key suitable for signing but isn't really the key itself - it's more a value used to seed a derived key.

Currently there isn't a way to export the key that is generated by NextAuth.js - though it's something we could certainly expose via the Node.js API and/or CLI in future. If you are curious what it looks like, you can find the code for it here.

If you want to generate your own key from that secret value you could write a function like this:

function getSigningKey (secret)  {
  const buffer = hkdf(secret, 64, { info: 'NextAuth.js Generated Signing Key', hash: 'SHA-256' })
  const key = jose.JWK.asKey(buffer, { alg: DEFAUL…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@jvorcak
Comment options

@iaincollins
Comment options

@jiveyTO
Comment options

@garretteklof
Comment options

@balazsorban44
Comment options

Answer selected by iaincollins
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants