Skip to content
ecdsa.com
jsonwebtoken (Node.js)JWT libraries

Error message

jwt issuer invalid. expected: https://login.example.com/

The text after "expected:" is whatever you configured; with an array of issuers the values are joined with commas.

jsonwebtoken (Node.js) — JsonWebTokenError from jwt.verify()

What it means

The token's `iss` claim is not equal to the `issuer` option you passed to `jwt.verify()` (or the token has no `iss` at all). The text after "expected:" is your configured value, not the token's. jsonwebtoken compares strings exactly, so the signature is valid but the token claims to come from somewhere your service does not trust.

Why it happens

How to fix it

  1. 1.

    Print the token's iss as JSON

    `JSON.stringify` makes invisible differences visible — trailing slashes, whitespace, a different path. Then copy the provider's `issuer` from `/.well-known/openid-configuration` into your configuration.

    js
    const { iss } = jwt.decode(token) ?? {};
    console.log(JSON.stringify(iss)); // compare byte for byte with your issuer option
  2. 2.

    Accept several issuers only deliberately

    The `issuer` option accepts an array. Use it for a planned migration between two spellings or issuers you control — and pair each issuer with its own keys.

    js
    jwt.verify(token, publicKey, {
      algorithms: ["ES256"],
      issuer: ["https://login.example.com/", "https://login.example.com"], // during a migration only
    });

Related errors

Browse the full signature error database