This is javascript for use with Postman's pre-request script feature. It makes POST request to Keycloak Token Endpoint to get a valid token and automatically set the token for all requests in Postman collection.
- Click edit on a collection and copy the content of keycloak-fetch-token-postman-pre-request.js into the "Pre-request Script" tab in Postman.
- In the Authorization tab set the Type to Bearer Token and Token to {{token}}. This is the token we created and set via the pre-request script.
- For all API requests: In the Authorization tab select Type - Inherit auth from parent
- ENJOY