Groovy Script
Explanation
This script performs the following operations:- Token Retrieval: JWT token is retrieved from Authorization header
- Payload Parsing: JWT token format is
header.payload.signature. Token is split by dot (.) character and payload part (second section) is retrieved - Base64 Decode: Payload part is Base64 encoded JSON format. This part is decoded
- JSON Parse: Decoded data is parsed as JSON
- Data Usage: Desired fields (e.g.,
username) are extracted and can be used
username field within the payload is retrieved and added to the header as usernameTest.
This script should be run on the request line (Request Policy) because it uses the
requestHeaderMapToTargetAPI variable.
