我正在尝试使用 Meteor 用户 hashedToken 访问 Restivus API
这是我的代码:
Transfer= new Mongo.Collection("transfer");
var Api = new Restivus({
useDefaultAuth: true,
auth: {
token: 'auth.apiKey',
user: function () {
return {
userId: this.request.headers['user-id'],
token: this.request.headers['login-token']
};
}
},
prettyJson: true
});
Api.addRoute('transfer', {authRequired: true}, {
post: function () {
var user = Meteor.users.findOne({_id:this.urlParams.id});
var userName = user.profile.name;
return {
userId: this.urlParams.id,
userName:userName
}
}
});
我试图用以下方式调用它:
curl -H "user-id: LGmaefwFZShu33GPA" -H "login-token: fG4HfWmPSp4Yd2HqUhNJEmAKcz4348Ng4WyyDaTHmLs=" http://localhost:3000/api/transfer
我收到了这个回复
{
"status": "error"
"message": "Unauthorized"
}