Token endpoint errors
The answers a code exchange or a refresh can get, and what to do with each.
POST <auth>/oauth/token answers errors in two formats. Read the status and handle both bodies.
RFC 6749 errors
HTTP 400 with a body like:
{ "error": "invalid_grant", "error_description": "Authorization code has expired" }
These are code exchange problems: an expired, used or unknown code, a wrong code_verifier or redirect_uri (invalid_grant); a missing parameter (invalid_request); a user blocked meanwhile (access_denied).
The Auth server's own errors
A body like {"code": 400, "error_code": "...", "msg": "..."}, as long as you send no X-Supabase-Api-Version header (with one, it becomes {"code": "<error_code>", "message": "..."}):
- Client authentication fails: 400,
error_codeinvalid_credentials. A wrong or rotated secret, or the secret not sent as HTTP Basic. - A refresh token that no longer works: 400,
error_coderefresh_token_not_found(the session was ended),refresh_token_already_used(reused after 10 seconds; the session is ended now),user_banned,session_not_foundorsession_expired. Treat every one as signed out. - The token was refused: 403,
error_codeunknown, with the reason inmsg. These come at the code exchange and at a refresh alike.
The 403s a frontend can meet
msg | When | What to do |
|---|---|---|
The frontend is for members only | Membership mandatory, and the user is not a member now. | Drop the session and send the user through sign-in again. |
OAuth tokens are issued for the scope openid only | The authorize request's scope was not exactly openid (none at all included). | Fix the authorize request; it is a bug in your frontend. |
The OAuth client is not an internal web frontend | Your client's frontend is not an internal frontend with the app type "Web app". | Drop the session; ask the organisation to check the frontend's "Sign-in" card. |
The OAuth client does not serve the frontend user's tenant | Your client ID is not (or no longer) a frontend of the user's organisation, for example after the client was recreated. | Check the client ID and secret you deploy against the "Sign-in" card, then send the user through sign-in again. |
The access token could not be issued | The token could not be computed (an internal error). | Treat as signed out; retry later, and report the time to appsolut if it repeats. |
Any other msg | Account or session states that no regular sign-in produces. | Treat as signed out, and report the msg and the time to appsolut. |