Skip to content

Instantly share code, notes, and snippets.

@paulonteri
Last active October 24, 2020 07:49
Show Gist options
  • Save paulonteri/025bb2d8a42baf9d72d6454a5cc748fb to your computer and use it in GitHub Desktop.
Save paulonteri/025bb2d8a42baf9d72d6454a5cc748fb to your computer and use it in GitHub Desktop.
Get auth token from postman
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
// check whether the request hast the Auth Token (auth_token)
var token;
pm.test("Body has auth_token", function () {
pm.expect(pm.response.text()).to.include("auth_token");
token = pm.response.json().auth_token
});
// save the auth token to an environment varaible AUTH_TOKEN
pm.test("Save token", function () {
pm.expect(token).to.be.a("string");
pm.environment.set("AUTH_TOKEN", token);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment