【发布时间】:2016-11-10 18:02:16
【问题描述】:
您好,我正在尝试从我的 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-3060-4329-a59e-3bd7f9ca90c8' } }
我做错了什么
【问题讨论】: