Created
December 5, 2019 11:20
-
-
Save alipandidan/b9526da09f89da653b71d70a065e1c5c to your computer and use it in GitHub Desktop.
Get bearer token automatically from API and use it in (Postman as Pre-request scipts)
This file contains 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
# Might be useful in Spring boot apps | |
const postRequest = { | |
url: 'http://<URL>/auth/login', | |
method: 'POST', | |
header: 'Content-Type:application/json', | |
body: { | |
mode: 'application/json', | |
raw: JSON.stringify( | |
{ | |
"username": <username>, | |
"password": <password> | |
}) | |
} | |
}; | |
pm.sendRequest(postRequest, function (err, res) { | |
pm.environment.set('accessToken', res.headers.get("X-Access-Token")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment