Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to set JWT Token as postman environment variable and use it for "Bearer Token" type in POST request Authorization


     Hi, 

    Bearer token response body: 

    {
    "token_field1": "TokenField1ValueInEncodedFormat",
    "token_lasts_for_howmanyms": 7200, //2 mins
    "type_of_token": "Bearer"
    }

    Write below script in "Tests" tab of SOAP POST request (not in Pre-request scripts)

    NOTE:
    Token generated will get stored in VarJWTToken where VarJWTToken is an environment variable created in the environment.  
    var data = JSON.parse(responseBody);
    postman.clearEnvironmentVariable(
    "VarJWTToken");
    postman.setEnvironmentVariable(
    "VarJWTToken", data.token_field1);

    Use the VarJWTToken environment variable in request Authorization as shown in below image: 
    request.png
    Postman collection format: 
    Token  (Token generated in this request will get stored in environment variable)
       SOAP POST Request (using environment variable POST authentication will be done) 

    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...