{"action":"created","comment":{"url":"https://api.github.com/repos/hammer-io/endor/pulls/comments/171133882","pull_request_review_id":99933052,"id":171133882,"diff_hunk":"@@ -124,6 +125,44 @@ export default class GithubAuthenticationService {\n     return tokenCreated;\n   }\n \n+  /**\n+   * First exchanges code and state for a github token.\n+   * Then adds a github token for the given user into the githubTokens table. If a token already\n+   * exists for the user, it will automatically update the old one.\n+   * @param userId the user id to add the token for\n+   * @param code the code to exchange for token\n+   * @param state the state to verify identity\n+   * @param username the github username of the user\n+   * @returns {Object} the token that was created\n+   */\n+  async getAndSetGithubTokenForUser(userId, code, state, username) {\n+    try {\n+      const secrets = config.get('oauth_secrets');\n+      const res = await fetch('https://cors-anywhere.herokuapp.com/https://github.com/login/oauth/access_token', {","path":"src/services/githubauth.service.js","position":31,"original_position":31,"commit_id":"d5fdb19f6f610509249628d512c32481740da949","original_commit_id":"d5fdb19f6f610509249628d512c32481740da949","user":{"login":"jackcmeyer","id":18731800,"avatar_url":"https://avatars3.githubusercontent.com/u/18731800?v=4","gravatar_id":"","url":"https://api.github.com/users/jackcmeyer","html_url":"https://github.com/jackcmeyer","followers_url":"https://api.github.com/users/jackcmeyer/followers","following_url":"https://api.github.com/users/jackcmeyer/following{/other_user}","gists_url":"https://api.github.com/users/jackcmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/jackcmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackcmeyer/subscriptions","organizations_url":"https://api.github.com/users/jackcmeyer/orgs","repos_url":"https://api.github.com/users/jackcmeyer/repos","events_url":"https://api.github.com/users/jackcmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/jackcmeyer/received_events","type":"User","site_admin":false},"body":"is cors anywhere secure?","created_at":"2018-02-28T03:17:03Z","updated_at":"2018-02-28T03:22:26Z","html_url":"https://github.com/hammer-io/endor/pull/56#discussion_r171133882","pull_request_url":"https://api.github.com/repos/hammer-io/endor/pulls/56","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/comments/171133882"},"html":{"href":"https://github.com/hammer-io/endor/pull/56#discussion_r171133882"},"pull_request":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/hammer-io/endor/pulls/56","id":171843724,"html_url":"https://github.com/hammer-io/endor/pull/56","diff_url":"https://github.com/hammer-io/endor/pull/56.diff","patch_url":"https://github.com/hammer-io/endor/pull/56.patch","issue_url":"https://api.github.com/repos/hammer-io/endor/issues/56","number":56,"state":"open","locked":false,"title":" Adding endpoints for exchanging codes for github and heroku tokens","user":{"login":"NathanDeGraaf","id":12648756,"avatar_url":"https://avatars1.githubusercontent.com/u/12648756?v=4","gravatar_id":"","url":"https://api.github.com/users/NathanDeGraaf","html_url":"https://github.com/NathanDeGraaf","followers_url":"https://api.github.com/users/NathanDeGraaf/followers","following_url":"https://api.github.com/users/NathanDeGraaf/following{/other_user}","gists_url":"https://api.github.com/users/NathanDeGraaf/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanDeGraaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanDeGraaf/subscriptions","organizations_url":"https://api.github.com/users/NathanDeGraaf/orgs","repos_url":"https://api.github.com/users/NathanDeGraaf/repos","events_url":"https://api.github.com/users/NathanDeGraaf/events{/privacy}","received_events_url":"https://api.github.com/users/NathanDeGraaf/received_events","type":"User","site_admin":false},"body":"Exchanging codes from redirects for actual access codes is done on the server so that the secrets can remain hidden. This adds the necessary endpoints to do so.","created_at":"2018-02-28T02:58:23Z","updated_at":"2018-02-28T03:22:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7c0694398fda39399f871c95435cd934ee013d7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hammer-io/endor/pulls/56/commits","review_comments_url":"https://api.github.com/repos/hammer-io/endor/pulls/56/comments","review_comment_url":"https://api.github.com/repos/hammer-io/endor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hammer-io/endor/issues/56/comments","statuses_url":"https://api.github.com/repos/hammer-io/endor/statuses/d5fdb19f6f610509249628d512c32481740da949","head":{"label":"hammer-io:nathandegraaf-oauth-endpoints","ref":"nathandegraaf-oauth-endpoints","sha":"d5fdb19f6f610509249628d512c32481740da949","user":{"login":"hammer-io","id":31553304,"avatar_url":"https://avatars1.githubusercontent.com/u/31553304?v=4","gravatar_id":"","url":"https://api.github.com/users/hammer-io","html_url":"https://github.com/hammer-io","followers_url":"https://api.github.com/users/hammer-io/followers","following_url":"https://api.github.com/users/hammer-io/following{/other_user}","gists_url":"https://api.github.com/users/hammer-io/gists{/gist_id}","starred_url":"https://api.github.com/users/hammer-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammer-io/subscriptions","organizations_url":"https://api.github.com/users/hammer-io/orgs","repos_url":"https://api.github.com/users/hammer-io/repos","events_url":"https://api.github.com/users/hammer-io/events{/privacy}","received_events_url":"https://api.github.com/users/hammer-io/received_events","type":"Organization","site_admin":false},"repo":{"id":119901052,"name":"endor","full_name":"hammer-io/endor","owner":{"login":"hammer-io","id":31553304,"avatar_url":"https://avatars1.githubusercontent.com/u/31553304?v=4","gravatar_id":"","url":"https://api.github.com/users/hammer-io","html_url":"https://github.com/hammer-io","followers_url":"https://api.github.com/users/hammer-io/followers","following_url":"https://api.github.com/users/hammer-io/following{/other_user}","gists_url":"https://api.github.com/users/hammer-io/gists{/gist_id}","starred_url":"https://api.github.com/users/hammer-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammer-io/subscriptions","organizations_url":"https://api.github.com/users/hammer-io/orgs","repos_url":"https://api.github.com/users/hammer-io/repos","events_url":"https://api.github.com/users/hammer-io/events{/privacy}","received_events_url":"https://api.github.com/users/hammer-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hammer-io/endor","description":"The backend web service for Yggdrasil.","fork":false,"url":"https://api.github.com/repos/hammer-io/endor","forks_url":"https://api.github.com/repos/hammer-io/endor/forks","keys_url":"https://api.github.com/repos/hammer-io/endor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hammer-io/endor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hammer-io/endor/teams","hooks_url":"https://api.github.com/repos/hammer-io/endor/hooks","issue_events_url":"https://api.github.com/repos/hammer-io/endor/issues/events{/number}","events_url":"https://api.github.com/repos/hammer-io/endor/events","assignees_url":"https://api.github.com/repos/hammer-io/endor/assignees{/user}","branches_url":"https://api.github.com/repos/hammer-io/endor/branches{/branch}","tags_url":"https://api.github.com/repos/hammer-io/endor/tags","blobs_url":"https://api.github.com/repos/hammer-io/endor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hammer-io/endor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hammer-io/endor/git/refs{/sha}","trees_url":"https://api.github.com/repos/hammer-io/endor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hammer-io/endor/statuses/{sha}","languages_url":"https://api.github.com/repos/hammer-io/endor/languages","stargazers_url":"https://api.github.com/repos/hammer-io/endor/stargazers","contributors_url":"https://api.github.com/repos/hammer-io/endor/contributors","subscribers_url":"https://api.github.com/repos/hammer-io/endor/subscribers","subscription_url":"https://api.github.com/repos/hammer-io/endor/subscription","commits_url":"https://api.github.com/repos/hammer-io/endor/commits{/sha}","git_commits_url":"https://api.github.com/repos/hammer-io/endor/git/commits{/sha}","comments_url":"https://api.github.com/repos/hammer-io/endor/comments{/number}","issue_comment_url":"https://api.github.com/repos/hammer-io/endor/issues/comments{/number}","contents_url":"https://api.github.com/repos/hammer-io/endor/contents/{+path}","compare_url":"https://api.github.com/repos/hammer-io/endor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hammer-io/endor/merges","archive_url":"https://api.github.com/repos/hammer-io/endor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hammer-io/endor/downloads","issues_url":"https://api.github.com/repos/hammer-io/endor/issues{/number}","pulls_url":"https://api.github.com/repos/hammer-io/endor/pulls{/number}","milestones_url":"https://api.github.com/repos/hammer-io/endor/milestones{/number}","notifications_url":"https://api.github.com/repos/hammer-io/endor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hammer-io/endor/labels{/name}","releases_url":"https://api.github.com/repos/hammer-io/endor/releases{/id}","deployments_url":"https://api.github.com/repos/hammer-io/endor/deployments","created_at":"2018-02-01T22:24:42Z","updated_at":"2018-02-02T01:27:37Z","pushed_at":"2018-02-28T02:58:24Z","git_url":"git://github.com/hammer-io/endor.git","ssh_url":"git@github.com:hammer-io/endor.git","clone_url":"https://github.com/hammer-io/endor.git","svn_url":"https://github.com/hammer-io/endor","homepage":null,"size":804,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":6,"watchers":2,"default_branch":"master"}},"base":{"label":"hammer-io:master","ref":"master","sha":"26e9b62682b197f2fe0ae3002ff9b462c76fb43d","user":{"login":"hammer-io","id":31553304,"avatar_url":"https://avatars1.githubusercontent.com/u/31553304?v=4","gravatar_id":"","url":"https://api.github.com/users/hammer-io","html_url":"https://github.com/hammer-io","followers_url":"https://api.github.com/users/hammer-io/followers","following_url":"https://api.github.com/users/hammer-io/following{/other_user}","gists_url":"https://api.github.com/users/hammer-io/gists{/gist_id}","starred_url":"https://api.github.com/users/hammer-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammer-io/subscriptions","organizations_url":"https://api.github.com/users/hammer-io/orgs","repos_url":"https://api.github.com/users/hammer-io/repos","events_url":"https://api.github.com/users/hammer-io/events{/privacy}","received_events_url":"https://api.github.com/users/hammer-io/received_events","type":"Organization","site_admin":false},"repo":{"id":119901052,"name":"endor","full_name":"hammer-io/endor","owner":{"login":"hammer-io","id":31553304,"avatar_url":"https://avatars1.githubusercontent.com/u/31553304?v=4","gravatar_id":"","url":"https://api.github.com/users/hammer-io","html_url":"https://github.com/hammer-io","followers_url":"https://api.github.com/users/hammer-io/followers","following_url":"https://api.github.com/users/hammer-io/following{/other_user}","gists_url":"https://api.github.com/users/hammer-io/gists{/gist_id}","starred_url":"https://api.github.com/users/hammer-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammer-io/subscriptions","organizations_url":"https://api.github.com/users/hammer-io/orgs","repos_url":"https://api.github.com/users/hammer-io/repos","events_url":"https://api.github.com/users/hammer-io/events{/privacy}","received_events_url":"https://api.github.com/users/hammer-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hammer-io/endor","description":"The backend web service for Yggdrasil.","fork":false,"url":"https://api.github.com/repos/hammer-io/endor","forks_url":"https://api.github.com/repos/hammer-io/endor/forks","keys_url":"https://api.github.com/repos/hammer-io/endor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hammer-io/endor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hammer-io/endor/teams","hooks_url":"https://api.github.com/repos/hammer-io/endor/hooks","issue_events_url":"https://api.github.com/repos/hammer-io/endor/issues/events{/number}","events_url":"https://api.github.com/repos/hammer-io/endor/events","assignees_url":"https://api.github.com/repos/hammer-io/endor/assignees{/user}","branches_url":"https://api.github.com/repos/hammer-io/endor/branches{/branch}","tags_url":"https://api.github.com/repos/hammer-io/endor/tags","blobs_url":"https://api.github.com/repos/hammer-io/endor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hammer-io/endor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hammer-io/endor/git/refs{/sha}","trees_url":"https://api.github.com/repos/hammer-io/endor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hammer-io/endor/statuses/{sha}","languages_url":"https://api.github.com/repos/hammer-io/endor/languages","stargazers_url":"https://api.github.com/repos/hammer-io/endor/stargazers","contributors_url":"https://api.github.com/repos/hammer-io/endor/contributors","subscribers_url":"https://api.github.com/repos/hammer-io/endor/subscribers","subscription_url":"https://api.github.com/repos/hammer-io/endor/subscription","commits_url":"https://api.github.com/repos/hammer-io/endor/commits{/sha}","git_commits_url":"https://api.github.com/repos/hammer-io/endor/git/commits{/sha}","comments_url":"https://api.github.com/repos/hammer-io/endor/comments{/number}","issue_comment_url":"https://api.github.com/repos/hammer-io/endor/issues/comments{/number}","contents_url":"https://api.github.com/repos/hammer-io/endor/contents/{+path}","compare_url":"https://api.github.com/repos/hammer-io/endor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hammer-io/endor/merges","archive_url":"https://api.github.com/repos/hammer-io/endor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hammer-io/endor/downloads","issues_url":"https://api.github.com/repos/hammer-io/endor/issues{/number}","pulls_url":"https://api.github.com/repos/hammer-io/endor/pulls{/number}","milestones_url":"https://api.github.com/repos/hammer-io/endor/milestones{/number}","notifications_url":"https://api.github.com/repos/hammer-io/endor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hammer-io/endor/labels{/name}","releases_url":"https://api.github.com/repos/hammer-io/endor/releases{/id}","deployments_url":"https://api.github.com/repos/hammer-io/endor/deployments","created_at":"2018-02-01T22:24:42Z","updated_at":"2018-02-02T01:27:37Z","pushed_at":"2018-02-28T02:58:24Z","git_url":"git://github.com/hammer-io/endor.git","ssh_url":"git@github.com:hammer-io/endor.git","clone_url":"https://github.com/hammer-io/endor.git","svn_url":"https://github.com/hammer-io/endor","homepage":null,"size":804,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":6,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/56"},"html":{"href":"https://github.com/hammer-io/endor/pull/56"},"issue":{"href":"https://api.github.com/repos/hammer-io/endor/issues/56"},"comments":{"href":"https://api.github.com/repos/hammer-io/endor/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hammer-io/endor/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/hammer-io/endor/statuses/d5fdb19f6f610509249628d512c32481740da949"}},"author_association":"NONE"}}
{"actor":{"display_login":"jackcmeyer"}}