Authentication at a Glance
Two Types of Tokens (Cloud)
If you’re building on the Cloud platform, you’ll use two tokens:
Access token: identifies your app (machine-to-machine).
Session token: identifies the tenant and user (from the App Shell).
In a typical Cloud App, both tokens are in play: the session token tells you who, and the access token lets you act on their behalf.
Check out the Cloud Apps: Authentication & Login guide to learn more about Cloud Apps authentication (JWKS, AppBridge integration).
- JTL Cloud (OAuth 2.0)
- OnPremise (API Key)
Cloud Authentication (OAuth 2.0)
The Cloud API uses the OAuth 2.0 Client Credentials Flow. Your app’s backend authenticates with a client ID and secret, receives a short-lived JWT, and uses that JWT as a Bearer token for all API requests.Prerequisites
Your app must be registered in the Partner Portal. Registration creates an OAuth client with aClient ID and Client Secret.How the Flow Works
- Your backend sends its client credentials to the JTL Identity Provider
- The Identity Provider returns a short-lived JWT access token
- Your backend includes that token (along with the tenant ID) in every API request
Token Endpoint
Example request:
For a full implementation including caching, JWKS verification, and tenant mapping, see Cloud Apps: Authentication & Login.
Making Authenticated API Requests
Once you have an access token, include it in every API request along with the tenant ID.Base URL:Example request:
Check out the Cloud Apps: Authentication & Login guide to see how to get the tenant ID.
Token Lifecycle
Access tokens are short-lived and expire after a set period. Your app needs to handle this:- Cache the token and reuse it until it’s close to expiry
- Refresh proactively (e.g. when < 5 minutes remain)
- Handle
401 Unauthorizedby refreshing once and retrying
Security Schemes
Cloud endpoints are secured using one of two schemes:JTL Cloud vs. OnPremise Comparison
SCX Channel API Authentication
The SCX Channel API uses the same client credentials mechanism as the Cloud-ERP API. You request an access token, use it for API calls, and request a new one before it expires. This section applies only to Marketplace Channel integrations. Base URL:How the Flow Works
Requesting an Access Token
Example request:cURL
Using the Access Token
Include theauthToken as a Bearer token in all subsequent requests:
cURL
Token Lifecycle
SCX access tokens have a TTL (Time To Live) of 1 hour. Your app should:- Cache the token and reuse it until it’s close to expiry
- Monitor the
expiresInvalue and refresh proactively (e.g. when less than 5 minutes) - Refresh tokens before they expire to avoid failures during requests.
Best Practices
These practices apply regardless of which auth mechanism you’re using: Credential storage- Never hardcode credentials in source code. Use environment variables or a secrets manager.
- Never commit
.envfiles to version control. - Rotate credentials if you suspect they’ve been compromised.
- Cache tokens and reuse them. Don’t request a new token for every API call.
- Refresh proactively before expiry, not after receiving a 401 error.
- On a 401 response, refresh the token and retry the request once.
- Always use HTTPS for Cloud and SCX API calls.
- Validate session tokens server-side. Never trust tokens received from the client without verification.
- Request the minimum required scopes. Don’t request broader access than your app needs.
What’s Next?
API Keys & Tokens
Deeper dive into JWT structure, session tokens, and token management
patterns.
Cloud Apps: Authentication
Implementation guide for authentication in Cloud Apps: AppBridge,
session tokens, and the setup handshake.
Error Handling
How to handle auth errors, expired tokens, and common failure modes.