- Authentication
Authentication
Access token overview
Access tokens provide API authorization and contain:
- User identity information
- Role-based permissions
- Access scope definitions
These tokens enable the API to validate requests and determine appropriate access levels.
Authentication workflows
OrderCloud implements six authentication workflows based on OAuth2 and OpenID Connect standards:
- Password grant type
- Client credentials
- Anonymous shopping
- Token refresh
- Elevated password
- Single sign-on (OpenID Connect)
Password grant type workflow
Standard user authentication requiring:
- ClientID
- Scope (space-delimited role list)
- Username
- Password
- Grant type:
password
Note: Client secret required if defined on API client.
Example request:
Client credentials workflow
Backend system authentication requiring:
- ClientID
- Client secret
- Scope (space-delimited role list)
- Grant type:
client_credentials
Example request:
Anonymous shopping workflow
Enables guest browsing and checkout. See anonymous shopping documentation for implementation details.
Refresh token workflow
Enables session extension without re-authentication:
- Requires initial authentication
- API client must set
RefreshTokenDuration - Uses refresh token from initial authentication
Required parameters:
- ClientID
- Refresh token
- Grant type:
refresh_token
Example request:
Elevated password workflow
Enhanced security implementation requiring:
- ClientID
- Scope (space-delimited role list)
- Username
- Password
- Client secret
- Grant type:
password
Example request:
Single sign-on workflow
OpenID Connect integration enabling:
- Third-party authentication
- Social login support
- Enterprise SSO integration
See SSO implementation guide for details.
Error handling
Error response structure
Example error response:
Implementation note: Focus error handling on Errors[0].ErrorCode.
Authentication error codes
OAuth token endpoint errors:
| ErrorCode | Description | Recoverable |
|---|---|---|
Auth.InvalidUsernameOrPassword | Invalid credentials | Retry |
Auth.UsernameAndPasswordRequired | Missing credentials | Retry |
Auth.PasswordExpired | Password expiration | Password Reset |
Auth.InsecurePassword | Security requirements not met | Password Reset |
Auth.InsufficientRole | Unauthorized role request | No |
Auth.SellerNotActive | Inactive marketplace | No |
Auth.UserNotActive | Incomplete user setup | No |
Auth.LockedOut | Maximum attempts exceeded | No |
Password reset error codes
Password reset endpoint errors:
| ErrorCode | Description | Recoverable |
|---|---|---|
PasswordReset.CannotReusePassword | Recent password reuse | Retry |
PasswordReset.TooSoonToChange | Change frequency limit | Wait |
PasswordReset.InvalidVerification | Invalid reset token | No |
PasswordReset.LockedOut | Account locked | No |
PasswordReset.MissingOrInvalidClientID | Invalid client | No |
PasswordReset.MissingUsername | Missing username | No |
Authentication response handling
Successful authentication returns:
API request authorization:
Token revocation
Token invalidation occurs:
- Automatically on user deactivation
- After password reset
- Through explicit revocation endpoints
Revocation endpoints:
DELETE v1/adminusers/{userID}/tokensDELETE v1/buyers/{buyerID}/users/{userID}/tokensDELETE v1/suppliers/{supplierID}/users/{userID}/tokensDELETE v1/me/tokens(self-revocation)
Note: Revocation takes up to 20 seconds due to caching.