Answers for "how to generate bearer token in postman"

0

postman bearer token

// Add to collection pre scripts
// Also don’t forget to set auth in endpoint as {{access_token}}

let tokenUrl = 'Your url to get token';
let email = 'Your email';
let password = 'Your password';

if (pm.environment.name === 'Your env') {
    tokenUrl = 'Another env token url';
}

const getTokenRequest = {
  method: 'POST',
  url: tokenUrl,
  body: {
      mode: 'formdata',
      formdata: [
          { key: 'email', value: email },
          { key: 'password', value: password }
      ]
  }
};

pm.sendRequest(getTokenRequest, (err, response) => {
  const jsonResponse = response.json();
  const newAccessToken = jsonResponse.data.token;
  pm.variables.set('access_token', newAccessToken);
});
Posted by: Guest on June-16-2021
0

how to add client id and client secret in postman

[ Base URL: api-sandbox.dhl.com/dgff/transportation ]
Posted by: Guest on January-04-2021

Browse Popular Code Answers by Language