FIWARE Wirecloud:使用 X-FI-WARE-OAuth-Token 请求时出错 header

FIWARE Wirecloud: Error using X-FI-WARE-OAuth-Token request header

我们是 FINISH 加速器的一部分,正在使用 fiware 提供的 docker 容器在我们自己的服务器上部署 Wirecloud 和 KeyRock。

我们已经 KeyRock-IdM 设置并链接到 Wirecloud。我们正在尝试将 logged-in 用户令牌传递给 API,将 returns 数据传递给小部件。

我们在 github 代码中找到了有关 "X-FI-WARE..." headers 的文档,并编写了一个测试小部件(main.js,如下所示)。当部署在 fiware 实验室实例上时,它开箱即用。当使用 docker 容器部署到我们的本地安装时,它会出现以下错误:"Current user has not an active FIWARE profile"。我搜索了 settings.py 文件,但不知道这个错误是从哪里来的。我有 DEBUG=True 但日志中没有显示任何内容。用户 运行 小部件已通过 KeyRock IdM 登录。

/*jshint globalstrict:true */
/*global MashupPlatform, ObjectStorageAPI, StyledElements*/

(function () { 

"use strict";


var token_available = MashupPlatform.context.get('fiware_token_available');
var username = MashupPlatform.context.get('username');
alert(username + " has token?: " + token_available);

var url = MashupPlatform.prefs.get('keyRock_url');

var request = MashupPlatform.http.makeRequest(url, {
    requestHeaders: {
        "X-FI-WARE-OAuth-Token": "true",
        "X-FI-WARE-OAuth-GET-Parameter": "access_token"
    },
    method: "GET",
    onSuccess: function (response) {
        alert("Success:" + JSON.stringify(response.responseText));
        document.getElementById('response').textContent = response.responseText;
    },
    onFailure: function (response) {
        alert("Failed:" + JSON.stringify(response.responseText));
    },
    onComplete: function () {
    }
}
);


})();

我怎样才能找出问题所在?

从下面的评论中,更改了一个 python 脚本: 在 docker 容器中编辑 /usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py 文件,并将第 37 行从 raise ValidationError(error_msg) 替换为简单的 raise。

来自 /var/log/apache2/error.log 的日志在下面

[Fri May 06 07:12:33.745550 2016] [wsgi:error] [pid 13:tid 139955375367936] Internal Server Error: /cdp/https/account.lab.fiware.org/user [Fri May 06 07:12:33.745580 2016] [wsgi:error] [pid 13:tid 139955375367936] Traceback (most recent call last): [Fri May 06 07:12:33.745584 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/proxy/views.py", line 234, in proxy_request [Fri May 06 07:12:33.745587 2016] [wsgi:error] [pid 13:tid 139955375367936] response = WIRECLOUD_PROXY.do_request(request, url, request_method, workspace) [Fri May 06 07:12:33.745589 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/proxy/views.py", line 144, in do_request [Fri May 06 07:12:33.745592 2016] [wsgi:error] [pid 13:tid 139955375367936] processor.process_request(request_data) [Fri May 06 07:12:33.745594 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py", line 59, in process_request [Fri May 06 07:12:33.745597 2016] [wsgi:error] [pid 13:tid 139955375367936] token = get_access_token(request['user'], _('Current user has not an active FIWARE profile')) [Fri May 06 07:12:33.745599 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py", line 33, in get_access_token [Fri May 06 07:12:33.745602 2016] [wsgi:error] [pid 13:tid 139955375367936] if oauth_info.access_token is None: [Fri May 06 07:12:33.745604 2016] [wsgi:error] [pid 13:tid 139955375367936] File "/usr/local/lib/python2.7/site-packages/social/storage/base.py", line 41, in access_token [Fri May 06 07:12:33.745615 2016] [wsgi:error] [pid 13:tid 139955375367936] return self.extra_data.get('access_token') [Fri May 06 07:12:33.745618 2016] [wsgi:error] [pid 13:tid 139955375367936] AttributeError: 'unicode' object has no attribute 'get'

我猜你多加了一个“-”。尝试 "X-fiware-..."

看来问题与使用python-social-auth v0.2.18有关。请更新至 v0.2.19。有关此问题的更多信息,请参阅 github 中的 ticket

Docker 集线器包含伪造的 'Official' 图片

在尝试了 Alonzo 的建议并且日志没有给出明显的解决方案后,我决定再次检查我使用的 docker 图像是否值得信赖。

事实证明,我使用的 docker 图片 (wirecloud/fiware-wirecloud) 声称是官方参考实现,实际上是一个名为 [=30= 的人拥有的旧版本 (0.8) ].如果您在 docker 中心或 Kitematic 中搜索 Wirecloud,它是第一个出现的条目。

我升级到 docker 图像 fiware/wirecloud 0.9 版本,现在可以使用了。我可以看到传递到我的后端服务的访问令牌。

奇怪的是,我根据 https://wirecloud.conwet.etsiinf.upm.es/slides/attachments/objectstorage.wgt 上的 objectstorage.wgt 示例建模的测试小部件需要更新到新的 config.xml 格式才能进行测试。

我建议:

  • a link 到文档中 docker 集线器上的正确线云图像。
  • 联系 'Wirecloud' 用户并要求他们更改图片描述,或添加包含官方 docker 图片信息的评论。