{"action":"created","comment":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/36224318","id":36224318,"diff_hunk":"@@ -34,7 +34,7 @@ def __init__(self, sensor_service, config=None, poll_interval=None):\n         self._last_event_ids = {}\n \n     def setup(self):\n-        self._client = Github(self._config['token'])\n+        self._client = Github(self._config['token'] or None)","path":"packs/github/sensors/github_repository_sensor.py","position":5,"original_position":5,"commit_id":"4e78dcd3f1a815031144906cd8279f83436faf4c","original_commit_id":"4e78dcd3f1a815031144906cd8279f83436faf4c","user":{"login":"manasdk","id":1776099,"avatar_url":"https://avatars.githubusercontent.com/u/1776099?v=3","gravatar_id":"","url":"https://api.github.com/users/manasdk","html_url":"https://github.com/manasdk","followers_url":"https://api.github.com/users/manasdk/followers","following_url":"https://api.github.com/users/manasdk/following{/other_user}","gists_url":"https://api.github.com/users/manasdk/gists{/gist_id}","starred_url":"https://api.github.com/users/manasdk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manasdk/subscriptions","organizations_url":"https://api.github.com/users/manasdk/orgs","repos_url":"https://api.github.com/users/manasdk/repos","events_url":"https://api.github.com/users/manasdk/events{/privacy}","received_events_url":"https://api.github.com/users/manasdk/received_events","type":"User","site_admin":false},"body":"Actually the better way to write this would've been `self._config.get('token', None)` to avoid any exceptions.\r\n\r\nSince I've merged the change already I will pick-up the fix.\r\n\r\n(note to self - coffee before work is essential)","created_at":"2015-08-04T18:30:29Z","updated_at":"2015-08-04T18:30:29Z","html_url":"https://github.com/StackStorm/st2contrib/pull/260#discussion_r36224318","pull_request_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260","_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments/36224318"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/260#discussion_r36224318"},"pull_request":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260"}}},"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260","id":41587514,"html_url":"https://github.com/StackStorm/st2contrib/pull/260","diff_url":"https://github.com/StackStorm/st2contrib/pull/260.diff","patch_url":"https://github.com/StackStorm/st2contrib/pull/260.patch","issue_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/260","number":260,"state":"closed","locked":false,"title":"Fix empty token in config [github]","user":{"login":"armab","id":1533818,"avatar_url":"https://avatars.githubusercontent.com/u/1533818?v=3","gravatar_id":"","url":"https://api.github.com/users/armab","html_url":"https://github.com/armab","followers_url":"https://api.github.com/users/armab/followers","following_url":"https://api.github.com/users/armab/following{/other_user}","gists_url":"https://api.github.com/users/armab/gists{/gist_id}","starred_url":"https://api.github.com/users/armab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armab/subscriptions","organizations_url":"https://api.github.com/users/armab/orgs","repos_url":"https://api.github.com/users/armab/repos","events_url":"https://api.github.com/users/armab/events{/privacy}","received_events_url":"https://api.github.com/users/armab/received_events","type":"User","site_admin":false},"body":"When [token](https://github.com/StackStorm/st2contrib/blob/master/packs/github/config.yaml#L2) is \"\" (by default), it's considered as a string and thereby is passed to GitHub.\r\n\r\nError log:\r\n```log\r\n./st2sensorcontainer.log:Aug  4 15:15:04 localhost st2sensorcontainer[8549]: DEBUG 140284147443664 Requester [-] GET https://api.github.com/users/armab {'Authorization': 'token (oauth token removed)', 'User-Agent': 'PyGithub/Python'} null ==> 401 {'status': '401 Unauthorized', 'content-length': '83', 'x-github-media-type': 'github.v3; format=json', 'x-content-type-options': 'nosniff', 'content-security-policy': \"default-src 'none'\", 'access-control-expose-headers': 'ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval', 'x-github-request-id': 'BCF1757A:44CE:281107F:55C0D6F5', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'x-ratelimit-remaining': '55', 'server': 'GitHub.com', 'x-ratelimit-limit': '60', 'x-xss-protection': '1; mode=block', 'access-control-allow-credentials': 'true', 'date': 'Tue, 04 Aug 2015 15:15:01 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json; charset=utf-8', 'x-frame-options': 'deny', 'x-ratelimit-reset': '1438703854'} {\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}\r\n\r\n# st2sensorcontainer --config-file=/etc/st2/st2.conf --sensor-ref=github.GithubRepositorySensor\r\n2015-08-04 15:18:02,082 DEBUG [-] Using config files: /etc/st2/st2.conf\r\n2015-08-04 15:18:02,084 DEBUG [-] Using logging config: /etc/st2reactor/syslog.sensorcontainer.conf\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/dist-packages/st2reactor/container/sensor_wrapper.py\", line 466, in <module>\r\n    obj.run()\r\n  File \"/usr/lib/python2.7/dist-packages/st2reactor/container/sensor_wrapper.py\", line 325, in run\r\n    self._sensor_instance.setup()\r\n  File \"/opt/stackstorm/packs/github/sensors/github_repository_sensor.py\", line 40, in setup\r\n    user = self._client.get_user(repository_dict['user'])\r\n  File \"/opt/stackstorm/virtualenvs/github/local/lib/python2.7/site-packages/github/MainClass.py\", line 157, in get_user\r\n    \"/users/\" + login\r\n  File \"/opt/stackstorm/virtualenvs/github/local/lib/python2.7/site-packages/github/Requester.py\", line 169, in requestJsonAndCheck\r\n    return self.__check(*self.requestJson(verb, url, parameters, headers, input, cnx))\r\n  File \"/opt/stackstorm/virtualenvs/github/local/lib/python2.7/site-packages/github/Requester.py\", line 177, in __check\r\n    raise self.__createException(status, responseHeaders, output)\r\ngithub.GithubException.BadCredentialsException: 401 {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Bad credentials'}\r\n^C\r\n\r\n```\r\n\r\nLet's make it more user-friendly and less strict, so `token: \"\"` value is considered as `None`.","created_at":"2015-08-04T16:10:59Z","updated_at":"2015-08-04T18:30:29Z","closed_at":"2015-08-04T18:28:57Z","merged_at":"2015-08-04T18:28:57Z","merge_commit_sha":"c42952bc336749a061748a680fc7e7bae43e754e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260/commits","review_comments_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260/comments","review_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/260/comments","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/4e78dcd3f1a815031144906cd8279f83436faf4c","head":{"label":"armab:fix-github-empty-token","ref":"fix-github-empty-token","sha":"4e78dcd3f1a815031144906cd8279f83436faf4c","user":{"login":"armab","id":1533818,"avatar_url":"https://avatars.githubusercontent.com/u/1533818?v=3","gravatar_id":"","url":"https://api.github.com/users/armab","html_url":"https://github.com/armab","followers_url":"https://api.github.com/users/armab/followers","following_url":"https://api.github.com/users/armab/following{/other_user}","gists_url":"https://api.github.com/users/armab/gists{/gist_id}","starred_url":"https://api.github.com/users/armab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armab/subscriptions","organizations_url":"https://api.github.com/users/armab/orgs","repos_url":"https://api.github.com/users/armab/repos","events_url":"https://api.github.com/users/armab/events{/privacy}","received_events_url":"https://api.github.com/users/armab/received_events","type":"User","site_admin":false},"repo":{"id":35368550,"name":"st2contrib","full_name":"armab/st2contrib","owner":{"login":"armab","id":1533818,"avatar_url":"https://avatars.githubusercontent.com/u/1533818?v=3","gravatar_id":"","url":"https://api.github.com/users/armab","html_url":"https://github.com/armab","followers_url":"https://api.github.com/users/armab/followers","following_url":"https://api.github.com/users/armab/following{/other_user}","gists_url":"https://api.github.com/users/armab/gists{/gist_id}","starred_url":"https://api.github.com/users/armab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/armab/subscriptions","organizations_url":"https://api.github.com/users/armab/orgs","repos_url":"https://api.github.com/users/armab/repos","events_url":"https://api.github.com/users/armab/events{/privacy}","received_events_url":"https://api.github.com/users/armab/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/armab/st2contrib","description":"StackStorm integration packs for many common tools and also helpful tools to build integrations and automations with StackStorm.","fork":true,"url":"https://api.github.com/repos/armab/st2contrib","forks_url":"https://api.github.com/repos/armab/st2contrib/forks","keys_url":"https://api.github.com/repos/armab/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/armab/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/armab/st2contrib/teams","hooks_url":"https://api.github.com/repos/armab/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/armab/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/armab/st2contrib/events","assignees_url":"https://api.github.com/repos/armab/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/armab/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/armab/st2contrib/tags","blobs_url":"https://api.github.com/repos/armab/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/armab/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/armab/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/armab/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/armab/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/armab/st2contrib/languages","stargazers_url":"https://api.github.com/repos/armab/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/armab/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/armab/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/armab/st2contrib/subscription","commits_url":"https://api.github.com/repos/armab/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/armab/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/armab/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/armab/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/armab/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/armab/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/armab/st2contrib/merges","archive_url":"https://api.github.com/repos/armab/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/armab/st2contrib/downloads","issues_url":"https://api.github.com/repos/armab/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/armab/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/armab/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/armab/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/armab/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/armab/st2contrib/releases{/id}","created_at":"2015-05-10T11:37:52Z","updated_at":"2015-05-10T11:37:53Z","pushed_at":"2015-08-04T16:05:35Z","git_url":"git://github.com/armab/st2contrib.git","ssh_url":"git@github.com:armab/st2contrib.git","clone_url":"https://github.com/armab/st2contrib.git","svn_url":"https://github.com/armab/st2contrib","homepage":"http://www.stackstorm.com/community","size":2687,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"StackStorm:master","ref":"master","sha":"8fb471b8f6472431a41dd9628bea18f055412d3a","user":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"repo":{"id":24968227,"name":"st2contrib","full_name":"StackStorm/st2contrib","owner":{"login":"StackStorm","id":4969009,"avatar_url":"https://avatars.githubusercontent.com/u/4969009?v=3","gravatar_id":"","url":"https://api.github.com/users/StackStorm","html_url":"https://github.com/StackStorm","followers_url":"https://api.github.com/users/StackStorm/followers","following_url":"https://api.github.com/users/StackStorm/following{/other_user}","gists_url":"https://api.github.com/users/StackStorm/gists{/gist_id}","starred_url":"https://api.github.com/users/StackStorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StackStorm/subscriptions","organizations_url":"https://api.github.com/users/StackStorm/orgs","repos_url":"https://api.github.com/users/StackStorm/repos","events_url":"https://api.github.com/users/StackStorm/events{/privacy}","received_events_url":"https://api.github.com/users/StackStorm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StackStorm/st2contrib","description":"StackStorm integration packs for many common tools and also helpful tools to build integrations and automations with StackStorm.","fork":false,"url":"https://api.github.com/repos/StackStorm/st2contrib","forks_url":"https://api.github.com/repos/StackStorm/st2contrib/forks","keys_url":"https://api.github.com/repos/StackStorm/st2contrib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StackStorm/st2contrib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StackStorm/st2contrib/teams","hooks_url":"https://api.github.com/repos/StackStorm/st2contrib/hooks","issue_events_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/events{/number}","events_url":"https://api.github.com/repos/StackStorm/st2contrib/events","assignees_url":"https://api.github.com/repos/StackStorm/st2contrib/assignees{/user}","branches_url":"https://api.github.com/repos/StackStorm/st2contrib/branches{/branch}","tags_url":"https://api.github.com/repos/StackStorm/st2contrib/tags","blobs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StackStorm/st2contrib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StackStorm/st2contrib/git/refs{/sha}","trees_url":"https://api.github.com/repos/StackStorm/st2contrib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StackStorm/st2contrib/statuses/{sha}","languages_url":"https://api.github.com/repos/StackStorm/st2contrib/languages","stargazers_url":"https://api.github.com/repos/StackStorm/st2contrib/stargazers","contributors_url":"https://api.github.com/repos/StackStorm/st2contrib/contributors","subscribers_url":"https://api.github.com/repos/StackStorm/st2contrib/subscribers","subscription_url":"https://api.github.com/repos/StackStorm/st2contrib/subscription","commits_url":"https://api.github.com/repos/StackStorm/st2contrib/commits{/sha}","git_commits_url":"https://api.github.com/repos/StackStorm/st2contrib/git/commits{/sha}","comments_url":"https://api.github.com/repos/StackStorm/st2contrib/comments{/number}","issue_comment_url":"https://api.github.com/repos/StackStorm/st2contrib/issues/comments{/number}","contents_url":"https://api.github.com/repos/StackStorm/st2contrib/contents/{+path}","compare_url":"https://api.github.com/repos/StackStorm/st2contrib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StackStorm/st2contrib/merges","archive_url":"https://api.github.com/repos/StackStorm/st2contrib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StackStorm/st2contrib/downloads","issues_url":"https://api.github.com/repos/StackStorm/st2contrib/issues{/number}","pulls_url":"https://api.github.com/repos/StackStorm/st2contrib/pulls{/number}","milestones_url":"https://api.github.com/repos/StackStorm/st2contrib/milestones{/number}","notifications_url":"https://api.github.com/repos/StackStorm/st2contrib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StackStorm/st2contrib/labels{/name}","releases_url":"https://api.github.com/repos/StackStorm/st2contrib/releases{/id}","created_at":"2014-10-09T01:19:56Z","updated_at":"2015-07-24T21:32:13Z","pushed_at":"2015-08-04T18:28:59Z","git_url":"git://github.com/StackStorm/st2contrib.git","ssh_url":"git@github.com:StackStorm/st2contrib.git","clone_url":"https://github.com/StackStorm/st2contrib.git","svn_url":"https://github.com/StackStorm/st2contrib","homepage":"http://www.stackstorm.com/community","size":6054,"stargazers_count":26,"watchers_count":26,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":13,"forks":36,"open_issues":13,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260"},"html":{"href":"https://github.com/StackStorm/st2contrib/pull/260"},"issue":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/260"},"comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/issues/260/comments"},"review_comments":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260/comments"},"review_comment":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StackStorm/st2contrib/pulls/260/commits"},"statuses":{"href":"https://api.github.com/repos/StackStorm/st2contrib/statuses/4e78dcd3f1a815031144906cd8279f83436faf4c"}}}}