我是邮递员的新手。我正在尝试使用以下文档中提到的邮递员的预请求脚本自动刷新访问令牌的过程
预请求代码:
let tokenUrl = 'https://oauth.brightcove.com/v4/access_token';
let clientId = '-----------------------------------------';
let clientSecret ='---------------------------------------';
let getTokenRequest = {
method: 'POST',
url: tokenUrl,
auth: {
type: "basic",
basic: [
{ key: "username", value: clientId },
{ key: "password", value: clientSecret }
]
},
body: {
mode: 'urlencoded',
urlencoded: [
{ key: 'grant_type', value: 'client_credentials' }
]
}
};
pm.sendRequest(getTokenRequest, (err, response) => {
let jsonResponse = response.json(),
newAccessToken = jsonResponse.access_token;
console.log({ err, jsonResponse, newAccessToken })
pm.environment.set('accessToken', newAccessToken);
pm.variables.set('accessToken', newAccessToken);
});
运行 api 时,邮递员控制台显示以下错误
{{err: null, jsonResponse: {…}, newAccessToken: undefined} err: null jsonResponse: {…} error: "invalid_client" error_description: "The "client_id" 参数丢失,没有命名适用于的客户端注册请求的调用,或者未正确验证。” newAccessToken:未定义
被这个错误困住了将近 4-5 小时。谁能告诉我这里有什么问题?