当我运行下面的脚本时,我得到以下返回:
{"error": "access_denied", "error_description": "访问被拒绝"}
我该如何解决这个问题?
const request = require('request');
request({
url: 'access_token_uri',
method: 'POST',
auth: {
user: 'client_id',
pass: 'client_secret'
},
form: {
'grant_type': 'client_credentials'
}
}, function(err, res) {
var json = JSON.parse(res.body);
encrypt(json.access_token, 'word');
});
function encrypt(token, word){
request({
url: 'uri/encrypt',
method: 'POST',
auth: {
'bearer': token
},
body: word
}, function(err, res) {
console.log(res.body);
});
}