ecdsa.com
jsonwebtoken (Node.js)JWT libraries

Error message

jwt audience invalid. expected: <audience>

The placeholder is filled with your configured value, e.g. "jwt audience invalid. expected: api://orders".

What it means

The token verified cryptographically, but its aud claim does not match the audience your verifier requires. Audience checking exists so a token minted for one API cannot be replayed against another — the signature proves who issued the token, while aud proves which service it was issued for, and both checks must pass before the claims can be trusted.

Why it happens

How to fix it

  1. 1.

    Compare what the token carries with what you expect

    Print both sides. Fix whichever is wrong: the verifier's audience option, or the audience/resource parameter the client uses when requesting the token.

    js
    const { aud } = jwt.decode(token);
    console.log("token aud:", aud);           // e.g. "api://orders" or ["api://orders"]
    jwt.verify(token, key, {
      algorithms: ["ES256"],
      audience: "api://orders",              // must match exactly (string, array or RegExp)
    });
  2. 2.

    Accept legitimate variants explicitly

    If several identifiers are genuinely valid for this API, list them — do not drop the audience check to make the error go away.

    js
    jwt.verify(token, key, {
      algorithms: ["ES256"],
      audience: ["api://orders", "https://api.example.com"],
    });

Related errors

← Browse the full signature error database