{"action":"created","comment":{"url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/comments/34129224","id":34129224,"diff_hunk":"@@ -0,0 +1,73 @@\n+/**\n+ * Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U\n+ *\n+ * This file is part of fiware-cosmos (FI-WARE project).\n+ *\n+ * fiware-cosmos is free software: you can redistribute it and/or modify it under the terms of the GNU Affero\n+ * General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your\n+ * option) any later version.\n+ * fiware-tidoop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the\n+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License\n+ * for more details.\n+ *\n+ * You should have received a copy of the GNU Affero General Public License along with fiware-cosmos. If not, see\n+ * http://www.gnu.org/licenses/.\n+ *\n+ * For those usages not covered by the GNU Affero General Public License please contact with\n+ * francisco dot romerobueno at telefonica dot com\n+ */\n+\n+/**\n+ * Http REST client\n+ *\n+ * Author: frb\n+ */\n+\n+// Module dependencies\n+var https = require('https');\n+\n+function doAuthorizedRequest(host, port, path, method, clientId, clientSecret, data, callback) {\n+    console.log('[cosmos-auth -> IdM] Request: ' + method + ' https://' + host + ':' + port + path);\n+\n+    var headers = {\n+        'Authorization': 'Basic ' + new Buffer(clientId + \":\" + clientSecret).toString('base64'),\n+        'Content-Type': 'application/x-www-form-urlencoded',\n+        'Content-Length': Buffer.byteLength(data, 'utf8')\n+    }\n+\n+    console.log('[cosmos-auth -> IdM] ' + JSON.stringify(headers));\n+    console.log('[cosmos-auth -> IdM] ' + data);\n+\n+    var options = {\n+        host : host,\n+        port : port,\n+        path : path,\n+        method : method,\n+        headers: headers\n+    };\n+\n+    var request = https.request(options, function(response) {\n+        var result = '';\n+\n+        response.on('data', function(data) {\n+            result = data.toString();\n+        });\n+\n+        response.on('end', function() {\n+            console.log('[cosmos-auth <- IdM] Response: ' + result)\n+            callback(null, result);\n+        });\n+    });\n+\n+    request.write(data);\n+    request.end();\n+\n+    request.on('error', function(error) {\n+        callback(error);\n+    });\n+} // doRequest\n+\n+\n+module.exports = {\n+    doAuthorizedRequest: doAuthorizedRequest\n+}","path":"cosmos-auth/src/client.js","position":73,"original_position":73,"commit_id":"859f2cfdbe9fdbc6628a6623d8555d895aacdaf8","original_commit_id":"c240500926cd3dc0816759abe9f9bc2710251eb5","user":{"login":"frbattid","id":3865056,"avatar_url":"https://avatars.githubusercontent.com/u/3865056?v=3","gravatar_id":"","url":"https://api.github.com/users/frbattid","html_url":"https://github.com/frbattid","followers_url":"https://api.github.com/users/frbattid/followers","following_url":"https://api.github.com/users/frbattid/following{/other_user}","gists_url":"https://api.github.com/users/frbattid/gists{/gist_id}","starred_url":"https://api.github.com/users/frbattid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbattid/subscriptions","organizations_url":"https://api.github.com/users/frbattid/orgs","repos_url":"https://api.github.com/users/frbattid/repos","events_url":"https://api.github.com/users/frbattid/events{/privacy}","received_events_url":"https://api.github.com/users/frbattid/received_events","type":"User","site_admin":false},"body":"Fixed in https://github.com/telefonicaid/fiware-cosmos/commit/859f2cfdbe9fdbc6628a6623d8555d895aacdaf8","created_at":"2015-07-08T09:16:45Z","updated_at":"2015-07-08T09:16:45Z","html_url":"https://github.com/telefonicaid/fiware-cosmos/pull/11#discussion_r34129224","pull_request_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/comments/34129224"},"html":{"href":"https://github.com/telefonicaid/fiware-cosmos/pull/11#discussion_r34129224"},"pull_request":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11","id":39362931,"html_url":"https://github.com/telefonicaid/fiware-cosmos/pull/11","diff_url":"https://github.com/telefonicaid/fiware-cosmos/pull/11.diff","patch_url":"https://github.com/telefonicaid/fiware-cosmos/pull/11.patch","issue_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/11","number":11,"state":"open","locked":false,"title":"feature/10_token_generator","user":{"login":"frbattid","id":3865056,"avatar_url":"https://avatars.githubusercontent.com/u/3865056?v=3","gravatar_id":"","url":"https://api.github.com/users/frbattid","html_url":"https://github.com/frbattid","followers_url":"https://api.github.com/users/frbattid/followers","following_url":"https://api.github.com/users/frbattid/following{/other_user}","gists_url":"https://api.github.com/users/frbattid/gists{/gist_id}","starred_url":"https://api.github.com/users/frbattid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbattid/subscriptions","organizations_url":"https://api.github.com/users/frbattid/orgs","repos_url":"https://api.github.com/users/frbattid/repos","events_url":"https://api.github.com/users/frbattid/events{/privacy}","received_events_url":"https://api.github.com/users/frbattid/received_events","type":"User","site_admin":false},"body":"* Implements issue #10 \r\n* No unit tests yet implemented.\r\n* (unofficial) e2e tests passed:\r\n```\r\n$ /Users/frb/.nvm/v0.10.38/bin/npm start\r\n\r\n> cosmos-auth@0.0.0 start /Users/frb/devel/fiware/fiware-cosmos/cosmos-auth\r\n> node ./src/server.js\r\n\r\ncosmos-auth running at http://localhost:13000\r\n[user --> cosmos-auth] Request: GET /tidoop/v1/version\r\n[user <-- cosmos-auth] Response: {version: 0.0.0}\r\n[user --> cosmos-auth] Request: POST /cosmos-auth/v1/token\r\n[user --> cosmos-auth] {\"user-agent\":\"curl/7.37.1\",\"host\":\"localhost:13000\",\"accept\":\"*/*\",\"content-type\":\"application/x-www-form-urlencoded\",\"content-length\":\"57\"}\r\n[user --> cosmos-auth] grant_type=password&username=frb@tid.es&password=xxxxxxxx\r\n[cosmos-auth -> IdM] Request: POST https://account.lab.fiware.org:443/oauth2/token\r\n[cosmos-auth -> IdM] {\"Authorization\":\"Basic xxxxxxxxxxxxxxxx\",\"Content-Type\":\"application/x-www-form-urlencoded\",\"Content-Length\":57}\r\n[cosmos-auth -> IdM] grant_type=password&username=frb@tid.es&password=xxxxxxxx\r\n[cosmos-auth <- IdM] Response: {\"access_token\": \"xxxxxxxx\", \"token_type\": \"Bearer\", \"expires_in\": 3600, \"refresh_token\": \"xxxxxxxx\"}\r\n[user <-- cosmos-auth] Response: {\"access_token\": \"xxxxxxxx\", \"token_type\": \"Bearer\", \"expires_in\": 3600, \"refresh_token\": \"xxxxxxxx\"}\r\n...\r\n$ curl -X GET \"http://localhost:13000/cosmos-auth/v1/version\"\r\n{version: 0.0.0}\r\n$ curl -X POST \"http://localhost:13000/cosmos-auth/v1/token\" -H \"Content-Type: application/x-www-form-urlencoded\" -d \"grant_type=password&username=frb@tid.es&password=xxxxxxxx\"\r\n{\"access_token\": \"xxxxxxxx\", \"token_type\": \"Bearer\", \"expires_in\": 3600, \"refresh_token\": \"xxxxxxxx\"}\r\n```\r\n* Assignee @gtorodelvalle ","created_at":"2015-07-07T12:10:42Z","updated_at":"2015-07-08T09:16:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f5aa820ba3cfcd304dc52161d1a1e7afc429536d","assignee":{"login":"gtorodelvalle","id":667284,"avatar_url":"https://avatars.githubusercontent.com/u/667284?v=3","gravatar_id":"","url":"https://api.github.com/users/gtorodelvalle","html_url":"https://github.com/gtorodelvalle","followers_url":"https://api.github.com/users/gtorodelvalle/followers","following_url":"https://api.github.com/users/gtorodelvalle/following{/other_user}","gists_url":"https://api.github.com/users/gtorodelvalle/gists{/gist_id}","starred_url":"https://api.github.com/users/gtorodelvalle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtorodelvalle/subscriptions","organizations_url":"https://api.github.com/users/gtorodelvalle/orgs","repos_url":"https://api.github.com/users/gtorodelvalle/repos","events_url":"https://api.github.com/users/gtorodelvalle/events{/privacy}","received_events_url":"https://api.github.com/users/gtorodelvalle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11/commits","review_comments_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11/comments","review_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/11/comments","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/statuses/859f2cfdbe9fdbc6628a6623d8555d895aacdaf8","head":{"label":"telefonicaid:feature/10_token_generator","ref":"feature/10_token_generator","sha":"859f2cfdbe9fdbc6628a6623d8555d895aacdaf8","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":37133407,"name":"fiware-cosmos","full_name":"telefonicaid/fiware-cosmos","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-cosmos","description":"fiware-cosmos toolkit for administration and support. Includes Sahara plugin","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-cosmos","forks_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/releases{/id}","created_at":"2015-06-09T13:24:13Z","updated_at":"2015-06-11T08:27:05Z","pushed_at":"2015-07-08T09:16:24Z","git_url":"git://github.com/telefonicaid/fiware-cosmos.git","ssh_url":"git@github.com:telefonicaid/fiware-cosmos.git","clone_url":"https://github.com/telefonicaid/fiware-cosmos.git","svn_url":"https://github.com/telefonicaid/fiware-cosmos","homepage":null,"size":1384,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":1,"default_branch":"master"}},"base":{"label":"telefonicaid:develop","ref":"develop","sha":"77cf569cf78921686d492ec029b9e33dd85243c8","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":37133407,"name":"fiware-cosmos","full_name":"telefonicaid/fiware-cosmos","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-cosmos","description":"fiware-cosmos toolkit for administration and support. Includes Sahara plugin","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-cosmos","forks_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-cosmos/releases{/id}","created_at":"2015-06-09T13:24:13Z","updated_at":"2015-06-11T08:27:05Z","pushed_at":"2015-07-08T09:16:24Z","git_url":"git://github.com/telefonicaid/fiware-cosmos.git","ssh_url":"git@github.com:telefonicaid/fiware-cosmos.git","clone_url":"https://github.com/telefonicaid/fiware-cosmos.git","svn_url":"https://github.com/telefonicaid/fiware-cosmos","homepage":null,"size":1384,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11"},"html":{"href":"https://github.com/telefonicaid/fiware-cosmos/pull/11"},"issue":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/11"},"comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/telefonicaid/fiware-cosmos/statuses/859f2cfdbe9fdbc6628a6623d8555d895aacdaf8"}}}}