fiwarefiware-wirecloud

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


We are part of the FINISH accelerator and are deploying Wirecloud and KeyRock on our own servers using the docker containers provided by fiware.

We have KeyRock-IdM set up and linked to Wirecloud. We are trying to pass the logged-in users token to an API which returns data to a widget.

We found documentation about the "X-FI-WARE..." headers in the github code and wrote a test widget (main.js shown below). When deployed on the fiware labs instance, it works out of the box. When deployed on our local installation with a docker container it gives the following error: "Current user has not an active FIWARE profile". I scoured the settings.py file but have no idea where this error is coming from. I have DEBUG=True but nothing show up in the log. The user running the widget was logged in through the 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 () {
    }
}
);


})();

How can i find out what is going wrong?

From the comment below, changed a python script: edited the /usr/local/lib/python2.7/site-packages/wirecloud/fiware/proxy.py file in the docker container and replaced line 37 from raise ValidationError(error_msg) to a simple raise.

the log from /var/log/apache2/error.log is below

[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'


Solution

  • Docker Hub contains bogus 'Official' images

    After trying Alonzo's suggestion and the log not yielding an obvious solution, i decided to double check that the docker image i was using was trustworthy.

    It turns out the docker image i was using (wirecloud/fiware-wirecloud) which states to be the official reference implementation is in fact an old version (0.8) owned by someone called 'Wirecloud'. If you search Wirecloud on docker hub or in Kitematic it is the first entry to show up.

    I upgraded to the docker image fiware/wirecloud which is version 0.9, and now it works. I can see the access token passed to my back-end services.

    Curiously, my test widget which i had modelled on the objectstorage.wgt example on https://wirecloud.conwet.etsiinf.upm.es/slides/attachments/objectstorage.wgt required updating to the new config.xml format before i could test.

    I suggest: