Skip to main content
err:unkey:authentication:portal_session_not_found
The portal session token or exchange code you sent doesn’t match an active session. You get HTTP 401.
Example response

Likely causes

  • The session in the portal_session cookie expired or was revoked. The message is the same for an unknown token, so it doesn’t say which.
  • On portal.exchangeCode, the code was already used, has expired, or was never issued. The message is Session is invalid, expired, or has already been used. A code works once, so a second exchange fails even if the first succeeded.

How to fix

  1. Start a new session from your backend with portal.createSession and complete the exchange promptly.
  2. If your frontend retries portal.exchangeCode on a slow network, keep the access token from the first success instead of exchanging again.
  3. If an active session starts returning this error, send the user back through your login flow.
Last modified on October 6, 2026