您好,我正在尝试从nodejs服务器向ionicframework API发送推送通知,我收到了一个错误,以下是我的代码
var token = '66a5c472b52d3210b591f717b5b996312f8xxxxxxxxxxxx';
var title = 'test';
var message = 'message';
var options = {
method: 'POST',
url: 'https://api.ionic.io/push/notifications',
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
},
json : {
"send_to_all": true,
"profile" : "my-profile",
"notification": {
"title": title,
"message": message,
"android": {
"title": title,
"message": message
},
"ios": {
"title": title,
"message": message
}
}
}
};
request(options, function(err, response, body) {
if (err) throw new Error(err);
console.log(body);
});我得到了这个错误
{ error: {消息:'JWT解码错误发生。‘,链接:空,类型:’未授权‘},元:{状态: 401,版本:'2.0.0-beta.0',request_id:’75726406-30604329-a59e-3bd7f9ca90c8‘}}
我能做错什么呢?
发布于 2016-11-10 18:02:16
我认为你的授权头有问题。在header中您放置的是token,但请确保它是API token。
另外,首先发出一个邮递员请求,并检查它是否工作正常。仅在标题中添加内容类型和授权部分。
然后检查差异..
感谢基础
https://stackoverflow.com/questions/39939965
复制相似问题