Get Authentication Token
Step 1 of the API flow. Retrieve a JWT authentication token for accessing protected endpoints.
Endpoint: POST /auth/token
Headers:
Content-Type: application/jsonX-Org- Your organization identifierClient-Id- Your client ID from credentialsClient-Secret- Your client secret from credentialsEnvironment- Your environment nameProjectKey- Your project key
Request Body:
{
"username": "your_username",
"first_name": "first_name",
"last_name": "last_name"
}
Response:
{
"status": 200,
"data": {
"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "refresh_token_string",
"username": "your_username"
},
"message": "Authenticated"
}
Code Examples
- JavaScript
- cURL
// Using fetch API
const getAuthToken = async () => {
const response = await fetch('https://dev.arealtimetech.com/ws/auth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Org': 'your_organization',
'Client-Id': 'your_client_id',
'Client-Secret': 'your_client_secret',
'Environment': 'your_environment',
'ProjectKey': 'your_project_key'
},
body: JSON.stringify({
username: "your_username",
first_name: "first_name",
last_name: "last_name"
})
});
const data = await response.json();
const token = `Bearer ${data.data.access_token}`;
console.log('Token:', token);
return token;
};
// Call the function
const token = await getAuthToken();
curl -X POST "https://dev.arealtimetech.com/ws/auth/token" \
-H "Content-Type: application/json" \
-H "X-Org: your_organization" \
-H "Client-Id: your_client_id" \
-H "Client-Secret: your_client_secret" \
-H "Environment: your_environment" \
-H "ProjectKey: your_project_key" \
-d '{
"username": "your_username",
"first_name": "first_name",
"last_name": "last_name"
}'