使用keyrockvalidationtestingWeb应用程序时遇到问题

首先,我们在fiware实验室中设置我们的应用程序: 在这里输入图像描述

我们用来创build应用程序的代码是在这个网站上

我们改变的唯一的东西是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; 

在部署节点服务器时,我们将以下站点启动并运行(在同事的笔记本电脑上): 网站 你可以在9点到18点之间查看自己的情况。

当我们点击login后,我们被正确地带到用户可以validation的fiware站点: 认证

这是网站破裂的地方(它说网页不可用): 页面不可用

为了解决这个问题,我们只改变了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) }); }); 

这样做之后,我们已经重新启动服务器。 从这里我们再次按下login,并validation应用程序的使用情况,而不是我们得到的网站中断: 在这里输入图像描述

这里我们得出结论,响应是一个空的对象,因为undefined被打印出来。

我们在这里做错了什么?

检查它,问题是你正在使用一个错误的callbackURL。 如果您检查server.js ,则使用的callbackURL的path是/user_info ,要使用该path,首先需要在/login处检索到的req.session.access_token 。 只需更改回拨url:

config.callbackURL = 'http://panonit.com:8802/login';

而一切都应该工作。 还请记住在您的IdM应用程序configuration中更改它!

是的,这个问题是阿尔贝蒂尼斯指出的。 callbackURL必须是/ login以获取代码,并从中检索访问令牌。 然后用访问令牌您将能够检索用户信息。

BR