【发布时间】:2015-11-04 21:55:52
【问题描述】:
我们用于创建应用程序的代码位于this site
我们从那个链接唯一改变的是 config.js:
var config = {}
config.idmURL = 'https://account.lab.fiware.org/';
config.client_id = 'f9b5940d67a741a38039690e4d6e6c6f';
config.client_secret = 'c9f854c96c9e4c70a0d402bce3233a17';
config.callbackURL = 'http://panonit.com:8802/user_info';
// Depending on Grant Type:
// Authorization Code Grant: code
// Implicit Grant: token
config.response_type = 'code';
module.exports = config;
在部署节点服务器时,我们启动并运行了以下站点(在同事的笔记本电脑上): 您可以在欧洲中部时间 09 点到 18 点之间亲自查看。
点击登录后,我们会正确转到用户可以进行身份验证的固件站点:
为了解决这个问题,我们只将 server.js 更改为只输出响应:
// Ask IDM for user info
app.get('/user_info', function(req, res){
var url = config.idmURL + '/user/';
// Using the access token asks the IDM for the user info
oa.get(url, req.session.access_token, function (e, response) {
//var user = JSON.parse(response);
var user = response;
console.log("Getting user response is: " + user)
//res.send("Welcome " + user.displayName + "<br> Your email address is " + user.email + "<br><br><button onclick='window.location.href=\"/logout\"'>Log out</button>");
res.send("Welcome " + user)
});
});
完成此操作后,我们重新启动了服务器。从这里我们再次按下登录并验证应用程序的使用,而不是我们得到的站点中断:
这里我们已经得出结论,响应是一个空对象,因为 undefined 被打印出来了。
我们在这里做错了什么?
【问题讨论】:
标签: javascript node.js oauth-2.0 fiware