curl -X POST 'https://api.weir.ai/auth/token' \
-H 'Content-Type: application/json' \
-u 'your_client_id:your_secret_key'
{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expiresIn": 3600,
"tokenType": "Bearer"
},
"message": "Access token generated successfully",
"status": "success"
}
Generate access tokens for external API authentication using client credentials
curl -X POST 'https://api.weir.ai/auth/token' \
-H 'Content-Type: application/json' \
-u 'your_client_id:your_secret_key'
{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expiresIn": 3600,
"tokenType": "Bearer"
},
"message": "Access token generated successfully",
"status": "success"
}
curl -X POST 'https://api.weir.ai/auth/token' \
-H 'Content-Type: application/json' \
-u 'your_client_id:your_secret_key'
{
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expiresIn": 3600,
"tokenType": "Bearer"
},
"message": "Access token generated successfully",
"status": "success"
}
Basic base64(client_id:secret_key)Show Token Data Properties
401 Unauthorized
{
"error": {
"code": "INVALID_CREDENTIALS",
"message": "Invalid client credentials",
"details": "The provided client ID or secret key is invalid"
},
"status": "error"
}
429 Too Many Requests
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many token generation requests",
"details": "Rate limit of 10 requests per minute exceeded"
},
"status": "error"
}
const generateAccessToken = async (clientId, secretKey) => {
const credentials = btoa(`${clientId}:${secretKey}`);
const response = await fetch('https://api.weir.ai/auth/token', {
method: 'POST',
headers: {
'Authorization': `Basic ${credentials}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.data.accessToken;
};
// Usage
const accessToken = await generateAccessToken('your_client_id', 'your_secret_key');
console.log('Access Token:', accessToken);
Credential Security
Token Security
Implement Token Caching
Handle Token Expiration
Monitor Rate Limits
Was this page helpful?