Last active
October 24, 2020 07:49
-
-
Save paulonteri/025bb2d8a42baf9d72d6454a5cc748fb to your computer and use it in GitHub Desktop.
Get auth token from postman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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