Auth error codes
Every error the Scrydon auth server returns carries a stable code. Branch on the code, never on the message, and translate by code.
When a call to the Scrydon auth server is refused, the response carries an
HTTP status and a JSON body with a code and a message:
{
"code": "ORGANIZATION_ADMIN_REQUIRED",
"message": "Only organization owners and admins can do this"
}| Field | What it is |
|---|---|
code | A stable identifier in UPPER_SNAKE_CASE. It does not change between releases unless the release notes say so. |
message | A sentence in English, for a person to read. Its wording can change in any release. |
Some codes also send extra fields that name what went wrong, for example the field that failed validation.
Branch on code, never on message
Your client should decide what to do from the code (and the HTTP status),
never from the message. A message can be reworded, corrected or shortened in
any release, so a check such as message.includes("admin") will break without
warning.
const { error } = await authClient.organization.setActive({ organizationId });
if (error?.code === "IDENTITY_NETWORK_NOT_ALLOWED") {
showNetworkHelp();
} else if (error) {
showError(error.message);
}Showing the error to a person
To show an error in the person's language, look the code up in your own
translations. When you have no translation for a code, show the message.
When there is neither, show a generic sentence of your own.
The Scrydon web apps follow this order, and they have a translation of every code in English, Spanish, French, German and Dutch.
Protocol endpoints
Two kinds of endpoints use the error format their standard defines instead:
| Endpoints | Format |
|---|---|
| OAuth 2.0 and OpenID Connect token and authorization endpoints | { "error": "invalid_grant", "error_description": "…" } (RFC 6749 §5.2). Branch on error. |
SCIM provisioning (/scim/v2/…) | { "schemas": [...], "status": "…", "detail": "…" } (RFC 7644 §3.12). Branch on status, and on scimType when it is present. |
An app that sends a person to sign in receives the OAuth error on its
redirect URI, for example error=access_denied.