Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. const url = postman.getEnvironmentVariable("host.api")+'/securityv2/v2/security/token/create';
  2. const user = postman.getEnvironmentVariable("cognito.user");
  3. const pass = postman.getEnvironmentVariable("cognito.pass");
  4. const client = postman.getEnvironmentVariable("client");
  5.  
  6. const requestConfig = {
  7. url: url,
  8. method: 'POST',
  9. header: {
  10. "Content-Type": "application/x-www-form-urlencoded"
  11. },
  12. body: {
  13. mode: 'raw',
  14. raw: 'username='+user+'&password='+pass+'&grant_type=password'+'&client_id='+client
  15. }
  16. };
  17.  
  18. pm.sendRequest(requestConfig, function (err, res) {
  19. console.log(err ? err : res.json());
  20. var data = res.json();
  21.  
  22. postman.setEnvironmentVariable("AuthToken", data.access_token);
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement