pawelklimczyk / keycloak-postman-pre-request

Postman pre-request script to fetch a token from Keycloak and set it to a collection variable to use in request headers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Postman pre-request script for authentication with Keycloak

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.

Usage

  1. 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.

Edit collection

  1. 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.

Edit collection

  1. For all API requests: In the Authorization tab select Type - Inherit auth from parent
  2. ENJOY

About

Postman pre-request script to fetch a token from Keycloak and set it to a collection variable to use in request headers.

License:MIT License


Languages

Language:JavaScript 100.0%