Authentication
API Authentication
Jeel APIs follows OAuth 2.1 for API authentication and authorization. Client Credentials flow will be used to authenticate by providing the authorization server with client id and secret to obtain a token for API usage.
The diagram below explains the flow
A sample HTTP request to get an access token
POST https://auth.sandbox.jeel.co/oauth2/token
replace https://auth.sandbox.jeel.co with https://auth.jeel.co when using production
Headers
Content-Type
multipart/form-data
Body
multipart form
client_id
string
Client id provided by Jeel Pay
client_secret
string
Client secret provided by Jeel Pay
grant_type
string
Always client_credentials
Response
Best Practices
⚠️ Important: The authentication endpoints are rate-limited. You must implement proper token caching to avoid hitting rate limits.
Always reuse valid tokens. Do not request a new token for every API call. Instead, store the access token after the first authentication and reuse it for subsequent requests until it expires.
Implementation Guidelines
Your authentication implementation should follow this caching logic:
Check for stored token - First, check if you have a previously saved access token in your cache/storage
Authenticate if no token exists - If no token is found, make an authentication request to obtain a new token
Store the token - Save the
access_tokenand calculate the expiration timestamp usingexpires_inValidate token expiration - Before using a stored token, verify it hasn't expired
Re-authenticate if expired - If the token is expired, request a new one and update your storage
Use valid cached token - If the token is still valid, use it for your API requests
Token Storage Considerations
Store the access token securely
Calculate and store the expiration timestamp:
current_time + expires_inThe
expires_invalue is in secondsConsider refreshing the token slightly before it expires to avoid edge cases (30 seconds is sufficient)
Example Workflow
Response Body
access_token
string
JWT access token for API authentication
token_type
string
Token type (always "Bearer")
expires_in
integer
Token validity duration in seconds
Security Notes
Never expose your
client_idandclient_secretin client-side codeStore credentials securely using environment variables or secret management systems
Use HTTPS for all authentication requests
Implement proper error handling for authentication failures
Last updated