Last active
October 3, 2024 19:59
-
-
Save crazyoptimist/b48671358a72e2857cfe0be33394a05e to your computer and use it in GitHub Desktop.
Postman Script for JWT Login
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
// Locate the "Scripts" tab in Postman. Select "Post-response" left side tab. Copy, paste, and edit this script. | |
const jsonData = pm.response.json() | |
// Make sure necessary variables exist in the response | |
pm.test("Access Token exists", function () { | |
pm.expect(jsonData.access_token).to.not.equal(undefined); | |
}); | |
pm.test("Refresh Token exists", function () { | |
pm.expect(jsonData.access_token).to.not.equal(undefined); | |
}); | |
// Set store them as env vars, to make use of them in other requests | |
pm.environment.set("access_token", jsonData.access_token) | |
pm.environment.set("refresh_token", jsonData.refresh_token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment