// guides · n8n error index

n8n JWT node not working: missing exp, Bearer, invalid algorithm, 54 runs

Fix the n8n JWT node: Payload Claims that never set exp, sub or aud, "Value is not a valid JWT token" from a Bearer prefix, "invalid algorithm", "The JWT token can't be verified", jwt expired, RS256 key errors, and Decode that checks nothing. 54 real runs on n8n 2.43.7.

Updated 2026-10-24 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. The Payload Claims fields do not set exp, sub, aud or iss

    This is the biggest trap. Signing with the Payload Claims fields Expires In 3600, Subject u1, Audience api://x and Issuer n8n gave a green run, but the payload was {"audience":"api://x","expiresIn":3600,"issuer":"n8n","subject":"u1","iat":...}. Those are plain keys, not the registered claims, so there is no exp, sub, aud or iss: the token never expires and an API that checks sub or aud rejects it. The fix we ran: turn on Use JSON to Build Payload and set Payload Claims (JSON) to an expression like {{ JSON.stringify({sub: $json.email, role: $json.role, exp: Math.floor(Date.now()/1000)+3600}) }}. That gave {"sub":"ann@example.com","role":"admin","exp":...,"iat":...}. With no claims at all the payload is only {"iat":...}.

  2. exp must be a number of seconds

    exp built with Date.now()+3600000 (milliseconds) was accepted silently: the token expires around the year 58,800, so it never expires in practice. Divide by 1000 and round, as above. exp as a string, "1893456000", failed with "exp" should be a number of seconds. Payload Claims (JSON) set to {{ $json }} worked too, but every input field became a claim, so check you are not putting private fields in the token. Relaxed JSON like { sub: 'u1' } was accepted.

  3. Fixed mode puts the braces in the token

    With the Payload Claims (JSON) field in Fixed mode, {"email":"{{ $json.email }}"} signed the literal text {{ $json.email }}, with a green run. Switch the field to Expression. For the header, Header Claims (JSON) {"kid":"key-1","typ":"JWT"} set kid, and Options > Key ID did the same. Three input items gave three tokens, one per item.

  4. Remove "Bearer " before Verify or Decode

    Pasting the token with Bearer in front into the Token field stopped the workflow before it started: The 'JWT' node has issues: - Value is not a valid JWT token. From an expression it failed with Invalid input for 'Token' [item 0]. The fix we ran: {{ $json.auth.replace(/^Bearer\s+/i, '') }}. In a webhook the header is $json.headers.authorization, see n8n webhook not working. A token with a trailing newline gave the same error, so add .trim(). An empty or missing token gave The JWT token was not provided.

  5. "The JWT token can't be verified": the secret does not match

    A wrong secret, the right secret with one trailing space in the credential, and a token whose issuer base64-decoded the secret before signing all failed with The JWT token can't be verified and the hint Be sure that the provided JWT token is correctly encoded and matches the selected credentials. Copy the secret again without spaces, and ask the issuer if their secret is base64 (many providers show it encoded). An empty secret failed at signing with secretOrPrivateKey must have a value.

  6. "invalid algorithm": Verify accepts one algorithm only

    A token signed HS512 checked with an HS256 credential, an HS256 token with an HS512 credential, and an RS256 token with an HS256 credential all failed with invalid algorithm. Verify only accepts the one algorithm set in the credential. Options > Override Algorithm fixed it: set to HS512, the HS512 token passed with the HS256 credential. The same option signs with another algorithm. Decode the token first to read the alg in its header.

  7. jwt expired and jwt not active

    A token that expired two minutes before failed with jwt expired. Options > Clock Tolerance 300 let it through, but not a token expired an hour before. Ignore Expiration let any expired token pass. A token with nbf one hour in the future failed with jwt not active, and Ignore Not Before Claim let it pass. One expired token among three items failed the whole node with no output for the two good ones.

  8. RS256 and ES256: the key must have its PEM lines

    A full PEM private key signed RS256 fine, and so did the same key pasted on one line with spaces. The base64 body without the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- lines failed with secretOrPrivateKey must be an asymmetric key when using RS256, and so did Key Type Passphrase with RS256. Only the public key filled gave secretOrPrivateKey must have a value when signing. To verify, the public key alone worked, but only the private key gave secret or public key must be provided. ES256 with an EC key worked; ES256 with an RSA key failed with "alg" parameter for "rsa" key type must be one of: RS256, PS256, RS384, PS384, RS512, PS512.

  9. Verify puts the claims under payload, and does not check aud or iss

    A good token came out as {"payload":{...}}, so the next node needs {{ $json.payload.sub }}, not $json.sub. Return Additional Info gave header, payload and signature at the top level. A token with an aud and iss of another service passed: the node has no option to require them, so check them with an IF node after Verify. With On Error set to continue, a bad token gave one item {"error":"The JWT token can't be verified"} and the input fields were gone.

  10. Decode checks nothing

    Decode returned the payload of a token signed with the wrong secret and of an expired token, both with green runs. Use it to read a token, never to trust one: use Verify for that. Decode still needs a credential: without one it failed with Node does not have any credentials set. A Bearer prefix fails Decode the same way as Verify.

What we ran

On 24 October 2026 we ran 54 executions of the JWT node v1 on self-hosted n8n 2.43.7 with n8n execute and 13 test credentials of type JWT Auth (HS256, HS512, a secret with a trailing space, an empty secret, RSA and EC PEM keys in several shapes). Test tokens were made with jsonwebtoken 9.0.3, the library n8n uses. 31 runs succeeded and 23 failed. Keys and secrets were throwaway test values.

What we ranResult
Sign, no claimsPayload {"iat":...}, HS256
Sign, Payload Claims Expires In, Subject, Audience, IssuerKeys expiresIn, subject... no exp, green
Sign, JSON payload with sub, role, exp in secondsRegistered claims set
Sign, JSON payload {{ $json }}Every input field is a claim
Sign, exp in millisecondsAccepted, never expires
Sign, exp as a stringError "exp" should be a number of seconds
Sign, relaxed JSON { sub: 'u1' }Accepted
Sign, JSON in Fixed mode with bracesLiteral {{ $json.email }} in the token
Sign, Header Claims kid / Options Key IDkid in the header
Sign, empty secretError secretOrPrivateKey must have a value
Sign RS256, full PEM / PEM on one lineWorks
Sign RS256, key body without BEGIN/END linesError secretOrPrivateKey must be an asymmetric key when using RS256
Sign RS256, public key onlyError secretOrPrivateKey must have a value
Sign RS256 with Key Type PassphraseError secretOrPrivateKey must be an asymmetric key when using RS256
Sign ES256 with an EC key / an RSA keyWorks / error "alg" parameter for "rsa" key type must be one of: RS256, PS256, RS384, PS384, RS512, PS512.
Sign, Override Algorithm HS512HS512 token from an HS256 credential
Sign, 3 items3 tokens
Verify, good token{"payload":{...}}
Verify, wrong secret / trailing space / base64 secretError The JWT token can't be verified
Verify, expired 2 minError jwt expired
Verify, expired, Ignore ExpirationPasses
Verify, expired 2 min / 1 h, Clock Tolerance 300Passes / jwt expired
Verify, nbf in 1 h / with Ignore Not BeforeError jwt not active / passes
Verify, Bearer in the Token fieldNot started: Value is not a valid JWT token
Verify, Bearer from an expression / trailing newlineError Invalid input for 'Token' [item 0]
Verify, replace(/^Bearer\s+/i, '')Passes
Verify, empty tokenError The JWT token was not provided
Verify, HS512 token with HS256 credential (and the reverse)Error invalid algorithm
Verify, same, Override Algorithm HS512Passes
Verify, RS256 token with HS256 credentialError invalid algorithm
Verify RS256, public key onlyPasses
Verify RS256, private key onlyError secret or public key must be provided
Verify RS256, key body without BEGIN/END linesError secretOrPublicKey must be an asymmetric key when using RS256
Verify, token with another aud and issPasses, not checked
Verify, Return Additional Infoheader, payload, signature
Verify, bad token, On Error continue{"error":...}, input fields gone
Verify, 3 items with 1 expiredWhole node fails jwt expired
Decode, wrong secret / expired tokenPayload returned, green
Decode, Bearer prefix / not-a-jwtError Value is not a valid JWT token
Decode, no credentialError Node does not have any credentials set

Quick checklist

Good to know

What we didn't test

FAQ

Why does my n8n JWT have no exp claim?

The Payload Claims fields Expires In, Subject, Audience and Issuer are written as plain keys (expiresIn, subject...), not as exp, sub, aud and iss. Turn on Use JSON to Build Payload and set exp yourself, in seconds.

What does "Value is not a valid JWT token" mean in n8n?

The Token field holds something that is not a bare JWT, usually "Bearer " in front or a trailing newline. Remove the prefix with replace(/^Bearer\s+/i, '') and add .trim().

Why do I get "invalid algorithm" in the n8n JWT node?

The token was signed with another algorithm than the one in the credential. Verify accepts only that one. Set Options > Override Algorithm to the token's alg, or fix the credential.

Why does n8n say "The JWT token can't be verified"?

The secret or public key does not match the one that signed the token. In our runs a trailing space or a secret that the issuer had base64-decoded gave the same error.

Does the n8n JWT node check audience and issuer?

No. A token with another aud and iss passed Verify in our run. Check $json.payload.aud and $json.payload.iss with an IF node.

Does Decode in the n8n JWT node verify the token?

No. It returned the payload of a token with a wrong signature and of an expired token. Use Verify before you trust the claims.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.