GuidesError HandlingError Messages

Authentication

Arkos maps authentication and JWT failures to consistent error responses automatically. These errors fire during the authenticate and authorize middleware pipeline — you never need to handle them yourself unless you want to add custom behavior via authentication hooks.

Token Errors

These fire when Arkos processes the Authorization header or arkos_access_token cookie:

ScenarioMessageStatusCode
Token is malformed or tamperedInvalid token. Please log in again!401InvalidToken
Token has expiredYour token has expired, Please log again!401ExpiredToken
No token present on a protected routeYou are not logged in! Please log in to get access.401LoginRequired
Token valid but user no longer existsThe user belonging to this token does no longer exists401UserNoLongerExists
Password changed after token was issuedUser recently changed password! Please log in again.401PasswordChanged

Login Errors

These fire inside the built-in login endpoint:

ScenarioMessageStatusCode
Missing username or password fieldPlease provide both {field} and password400MissingCredentialFields
Wrong credentialsIncorrect {field} or password401IncorrectCredentials

Authorization Errors

This fires when an authenticated user lacks the required role or permission for a route:

ScenarioMessageStatusCode
Insufficient permissionsYou do not have permission to perform this action403NotEnoughPermissions

Password Update Errors

These fire inside the built-in update-password endpoint:

ScenarioMessageStatusCode
Missing currentPassword or newPasswordcurrentPassword and newPassword are required400SameCurrentAndNewPassword
currentPassword is wrongCurrent password is incorrect400IncorrentCurrentPassword

Customizing Authentication Error Behavior

If you need to run custom logic when authentication or authorization fails — logging, suppressing errors for guest access, integrating a third-party auth provider — use authentication hooks. Hooks let you tap into the authenticate and authorize pipeline without replacing the built-in behavior.