1
votes

I am creating a postman collection for one of API integration with our Service. Here we are using OAuth1.0 for authentication. I want to set the oauth init response oauth_token, oauth_token_secret into postman environment variables so that I can access them in further requests. The response is in below format not a JSON. oauth_token=oauth_token_value&oauth_token_secret=oauth_token_secret_value&oauth_callback_confirmed=true

I tried below script:

var output = require('querystring').parse(Response.text);
postman.setGlobalVariable("oauth_token", output.oauth_token);
postman.setGlobalVariable("oauth_token_secret", output.oauth_token_secret); 

Can some one help me to set tokens into postman environment variables please.

Note: I am using chrome plugin Version 5.5.4, not native app.

1
Use native app. - Divyang Desai

1 Answers

0
votes

In the chrome extension you need to use postman.setEnvironmentVariable():

postman.setEnvironmentVariable("oauth_token", output.oauth_token);
postman.setEnvironmentVariable("oauth_token_secret", output.oauth_token_secret);

For that you need to have an environment created and selected (no need to add any variable manually). How to do that is described here: https://learning.postman.com/docs/sending-requests/managing-environments/#creating-environments