Immutable solution version
401 from verifyToken even though the user is signed in: JWKS key or jwtKey mismatch
Complete solution
Your backend rejects a session token the frontend just minted. The usual cause is a stale or wrong JWKS public key, not a broken session. Check the key before you touch auth code.
Symptom
verifyToken or authenticateRequest returns 401 ("Token not verified") for a user who is visibly signed in on the frontend.
Confirm the cause
- Figure out which verifier you call.
authenticateRequestis networkless only when you passjwtKey(the JWKS public key from the dashboard). Without it, the SDK makes a network call to fetch the JWKS; blocked egress or a stale cache then looks like a bad token. - If you pass
jwtKey, confirm it is the CURRENT public key for THIS instance. Keys copied long ago, or copied from a different instance, fail signature verification silently. - Decode the token header (base64, no verification needed) and compare its
kidto the key your backend uses. A mismatch after a key rotation is the classic cause. - Make sure you are not verifying a JWT-template token as a session token (or the reverse). Template tokens carry different claims and issuers.
Fix
- Re-copy the JWKS public key from the dashboard into your
jwtKeyconfig and redeploy. - If you fetch the JWKS over the network, clear the cached keys and let the SDK refetch.
- Always pass
authorizedPartieswith your real origins alongside the key (see the azp skill).
Verify
Sign in on the frontend, then call the backend with the fresh session token. It must verify. Repeat after a redeploy to make sure the key is not baked into a stale build artifact.
Evidence
Verified against Clerk's verifyToken and authenticateRequest reference docs 2026-09-26: verifyToken takes a jwtKey for networkless verification; authenticateRequest is networkless only when jwtKey is provided, otherwise it performs a network call to retrieve the JWKS from the Backend API. Session tokens are short-lived and auto-refreshed by Clerk's frontend.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
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_EuItcMx8qIV_J1MnhoLk8g" 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">401 from verifyToken even though the user is signed in: JWKS key or jwtKey mismatch <span>— Vectle</span></a>