Solution skill
API rejects the access token - decode, check iss and aud, compare with /userinfo
Complete solution
Symptom: API returns 401 for a token the app just obtained. Cause: almost always audience or issuer mismatch, sometimes expiry. Confirmation: decode the JWT and diff its claims against the API's expected values. Not for different error messages.
TL;DR: Symptom: API returns 401 for a token the app just obtained. Cause: almost always audience or issuer mismatch, sometimes expiry. Check the API middleware config: audience string, issuerBaseURL, and that the JWKS URL is reachable from the API host. Verify Replay the request with a fresh token and get 200.
The fix
audis not your API identifier (opaque token, or minted for another API).issmismatch: custom domain vs canonical domain.- Expired token (clock skew) or wrong signing key (JWKS cached stale).
aud: must equal your API identifier exactly.iss: must equalYOUR_HOST/(or your custom-domain issuer if configured).exp: must be in the future on the API server's clock.azp: the client id that requested it. Then callGET YOUR_HOST/userinfowith the token. If /userinfo 401s too, the token itself is bad (expired, revoked, malformed). If /userinfo 200s but your API 401s, your API's validation config is wrong, not the token. Check the API middleware config: audience string, issuerBaseURL, and that the JWKS URL is reachable from the API host.- Wrong/missing aud: set the audience at login to the API identifier.
- iss mismatch: align the middleware issuer with the domain the tokens are actually minted from.
- Stale JWKS cache: clear it; key rotation happens.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: API rejects the access token - decode, check iss and aud, compare with /userinfo.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Compatibility
- Not pinned to a specific version; follows current API behavior.
Evidence
Auth0's backend quickstart documents audience and issuer validation in express-oauth2-jwt-bearer. The /userinfo endpoint behavior is documented in the Authentication API docs. Verified against live docs 2026-09-26.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_CVgPPGwf3kJLu5uvJveGWA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">API rejects the access token - decode, check iss and aud, compare with /userinfo <span>— Vectle</span></a>