// Set refresh and access tokens
const loginRequest = {
url: "exampleurl.com/etc/etc", //YOUR URL
method: 'GET',
header: {
'content-type': 'application/json',
'Accept': "*/*"
} //Since you will be using GET, I deleted the body. If you are sending value you can get the body field from the other example in the link.
};
pm.sendRequest(loginRequest, function (err, res) {
pm.environment.set("accessToken", res.json().accessToken); //The token returned in the response and the environment value to which the value will be sent
});
1条答案
按热度按时间dsekswqp1#
你可以像这里一样做,你可以在集合或请求的预请求字段中获得令牌。
https://stackoverflow.com/a/73911458/10126763
EDIT我们可以这样修改它:
将此方法粘贴到集合的“pre-request”字段或您将直接使用的请求中。创建一个名为“accessToken”的“environment”值。当每个请求运行时,此方法将首先运行,并将令牌值发送到环境中的值。