Skip to main content

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/json
  • X-Org - Your organization identifier
  • Client-Id - Your client ID from credentials
  • Client-Secret - Your client secret from credentials
  • Environment - Your environment name
  • ProjectKey - 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

// 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();