【发布时间】:2020-09-18 00:51:29
【问题描述】:
此时我可以成功执行我的邮递员请求以获取我的令牌。我正在使用这些参数:
-标题中的基本授权
现在我想将此请求作为预请求脚本(并为令牌使用环境变量)。
这是脚本:
pm.sendRequest({
url: 'http://localhost:8084/oauth/token',
method: 'POST',
header: {
'Authorization':'Basic Y2xpZW50OnBhc3N3b3Jk',
'content-type': 'application/x-www-form-urlencoded'
},
data:{
'password':'secret',
'username':'admin',
'grant_type':'password'
}
}, (err, res) => pm.environment.set("token", res.json().access_token));
它不适用于响应:Full authentication is required to access this resource。
怎么了?
谢谢
【问题讨论】:
标签: javascript spring-security postman urlencode