Access Token Generation (Client Credentials)#
This guide explains how to generate an OAuth2 access token using the Client Credentials flow.Endpoint: POST /oauth2/token
Base URL: https://api.hyblockcapital.com/v2
Body: application/x-www-form-urlencoded
Grant Type: client_credentials
1) Prerequisites#
These credentials are used only for generating an access token.
2) Token Endpoint Spec#
Request#
https://api.hyblockcapital.com/v2/oauth2/token
grant_type=client_credentials
The Authorization header must be:Authorization: Basic BASE64(client_id:client_secret)
client_id:client_secret -> Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=
Authorization: Basic Y2xpZW50X2lkOmNsaWVudF9zZWNyZXQ=
4) cURL Example#
Successful response returns:{
"access_token": "<token>",
"expires_in": 84706,
"token_type": "Bearer"
}
access_token: token required for all protected API endpoints
expires_in: token TTL (seconds)
6) Use Token in API Requests#
7) Token Caching Strategy (Recommended)#
Because tokens expire (expires_in), implement:Cache token (memory / redis)
2.
If missing/expired → request new token
8) Common Errors#
401 Unauthorized#
Incorrect base64 encoding (must be client_id:client_secret)
Using Bearer instead of Basic for /oauth2/token
403 Forbidden#
Missing/invalid x-api-key
415 Unsupported Media Type#
Wrong Content-Type (must be application/x-www-form-urlencoded
Modified at 2026-01-30 06:17:40