Authentication - Obtaining a Token
To start generating reports in Speaknosis, you must first obtain an authentication token. Make a POST request to the following endpoint, depending on your environment:
👨🏻💻 Development Environment:
POST https://api-dev.speaknosis.com/api/iam/integration/token
👨🏻💻 QA environment:
POST https://api-qa.speaknosis.com/api/iam/integration/token
🏥 Production Environment:
POST https://api-prod.speaknosis.com/api/iam/integration/token
Example Request Body (application/x-www-form-urlencoded
):
grant_type=client_credentials&client_id=client_id&client_secret=client_secret
Code Example (JavaScript):
const loginDataObject = new URLSearchParams({
grant_type: "client_credentials",
client_id: "client_id",
client_secret: "client_secret",
});
const requestOptions = {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: loginDataObject,
};
// Example using fetch API
fetch("YOUR_API_ENDPOINT", requestOptions)
.then(response => response.json())
.then(data => {
console.log('Token:', data.access_token);
// Store the access_token and use it in subsequent requests
})
.catch(error => console.error('Error fetching token:', error));
Remember to replace "client_id"
and "client_secret"
with your provided credentials. Also replace YOUR_API_ENDPOINT
with the appropriate development or production URL.
The successful response (code 200 OK) will contain the access_token
in JSON format:
{
"access_token": "YOUR_ACCESS_TOKEN",
"token_type": "Bearer"
}