Postman
To do some initial testing before you write your integration code, you can use tools like Postman
Doing the calls to our services should be fairly self-explanatory, but authentication requires a bit more work:
Steps:
- Create your authentication credentials (see here)
- Create a small tool program that uses the certificate to authenticate, and create the access_token (See example code here)
- In Postman:
- Create a new request
- Set the Method and Url to point to our service
- Run the tool program to generate the token, and paste in the token
- Under "Authorization", select "Bearer Token" and insert the generated token
- Send the request (Repeat until the token expires after 60 minutes)
Auto-renew token in Postman
If you do not want to manually renew the access_token every 60 minutes, you can expose your tool program as a HTTP-api, and update the token as part of the "Pre-request script in Postman"
Steps:
- Convert your tool program into a API that returns the access_token in its HTTP response
- Run the API on localhost
- Under "Authorization" in Postman, change the token value to a variable:
{{access_token}}
- Add the following script under "Pre-request script":
const reqObject = {
url: 'http://localhost:9999/', // Url to the tool program that is creating access_tokens
method: 'GET'
};
pm.sendRequest(reqObject, (err, res) => {
console.log(`fetched token ${res}`)
pm.environment.set("access_token", res); // Set variable based on http response
});