{"action":"created","comment":{"url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/comments/189555026","pull_request_review_id":119758756,"id":189555026,"diff_hunk":"@@ -28,6 +30,77 @@\n \t\t\tcallback(error, collectionItems, additionalData);\n \t\t}, false);\n \t};\n+\texports.OAuthAuthenticate = function (client_id, redirect_uri, res) {\n+\t    res.redirect('https://oauth.pipedrive.com/oauth/authorize?' +\n+            qs.stringify({\n+                client_id: client_id,\n+                redirect_uri: redirect_uri,\n+            }))\n+\t};\n+\n+\texports.OAuthAuthenticateCallback = function (req, res, redirect_uri, clientId, clientSecret) {\n+\t    var code = req.query.code || null;\n+\t    var authOptions = {\n+\t        url: 'https://oauth.pipedrive.com/oauth/token',\n+            form: {\n+\t            code: code,\n+                redirect_uri: redirect_uri,\n+                grant_type: 'authorization_code'\n+            },\n+\t\t\theaders: {\n+\t\t\t\t'Authorization': getBasicAuthHeader(clientId, clientSecret)\n+\t\t\t},\n+            json: false\n+\t    };\n+\t    return new Promise(function (resolve) {\n+\t\t\tvar req = rest.post(authOptions.url,\n+\t\t\t\t{\n+\t\t\t\t\tjson: authOptions.json,\n+\t\t\t\t\tmultipart: false,\n+\t\t\t\t\tdata: authOptions.form,\n+\t\t\t\t\tbasic_auth: authOptions.headers['Authorization']\n+\t\t\t\t});\n+\n+\t\t\treq.on('complete', function(data) {\n+\t\t\t\tvar body = JSON.parse(data);\n+\t\t\t\tresolve(body)\n+\t\t\t});\n+\t    })\n+\t};\n+\n+\texports.OAuthRefreshToken = function (req, res, refresh_token, clientId, clientSecret) {\n+\t    var refreshOptions = {\n+\t        url: 'https://oauth.pipedrive.com/oauth/token',\n+            form: {\n+                refresh_token: refresh_token,\n+                grant_type: 'refresh_token'\n+            },\n+            headers: {\n+\t\t\t\t'Authorization': getBasicAuthHeader(clientId, clientSecret)\n+\t\t\t},\n+            json: false\n+\t    };\n+\t    return new Promise(function (resolve) {\n+\t\t\tvar req = rest.post(refreshOptions.url,\n+\t\t\t\t{\n+\t\t\t\t\tjson: refreshOptions.json,\n+\t\t\t\t\tmultipart: false,\n+\t\t\t\t\tdata: refreshOptions.form,\n+\t\t\t\t\tbasic_auth: refreshOptions.headers['Authorization']\n+\t\t\t\t});\n+\n+\t\t\treq.on('complete', function(data) {\n+\t\t\t\tvar body = JSON.parse(data);","path":"lib/Pipedrive.js","position":75,"original_position":75,"commit_id":"d1283871d98ec48274cb162d5cd674d54e486398","original_commit_id":"d1283871d98ec48274cb162d5cd674d54e486398","user":{"login":"deespater","id":114211,"avatar_url":"https://avatars0.githubusercontent.com/u/114211?v=4","gravatar_id":"","url":"https://api.github.com/users/deespater","html_url":"https://github.com/deespater","followers_url":"https://api.github.com/users/deespater/followers","following_url":"https://api.github.com/users/deespater/following{/other_user}","gists_url":"https://api.github.com/users/deespater/gists{/gist_id}","starred_url":"https://api.github.com/users/deespater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deespater/subscriptions","organizations_url":"https://api.github.com/users/deespater/orgs","repos_url":"https://api.github.com/users/deespater/repos","events_url":"https://api.github.com/users/deespater/events{/privacy}","received_events_url":"https://api.github.com/users/deespater/received_events","type":"User","site_admin":false},"body":"Same as `exports.OAuthAuthenticateCallback`","created_at":"2018-05-21T10:45:30Z","updated_at":"2018-05-21T10:47:20Z","html_url":"https://github.com/pipedrive/client-nodejs/pull/71#discussion_r189555026","pull_request_url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/comments/189555026"},"html":{"href":"https://github.com/pipedrive/client-nodejs/pull/71#discussion_r189555026"},"pull_request":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71"}}},"pull_request":{"url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71","id":183269086,"html_url":"https://github.com/pipedrive/client-nodejs/pull/71","diff_url":"https://github.com/pipedrive/client-nodejs/pull/71.diff","patch_url":"https://github.com/pipedrive/client-nodejs/pull/71.patch","issue_url":"https://api.github.com/repos/pipedrive/client-nodejs/issues/71","number":71,"state":"open","locked":false,"title":"OAuth authorization support","user":{"login":"annakrajuskina","id":14068753,"avatar_url":"https://avatars3.githubusercontent.com/u/14068753?v=4","gravatar_id":"","url":"https://api.github.com/users/annakrajuskina","html_url":"https://github.com/annakrajuskina","followers_url":"https://api.github.com/users/annakrajuskina/followers","following_url":"https://api.github.com/users/annakrajuskina/following{/other_user}","gists_url":"https://api.github.com/users/annakrajuskina/gists{/gist_id}","starred_url":"https://api.github.com/users/annakrajuskina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annakrajuskina/subscriptions","organizations_url":"https://api.github.com/users/annakrajuskina/orgs","repos_url":"https://api.github.com/users/annakrajuskina/repos","events_url":"https://api.github.com/users/annakrajuskina/events{/privacy}","received_events_url":"https://api.github.com/users/annakrajuskina/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-22T11:47:36Z","updated_at":"2018-05-21T10:47:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"14ca65d91b805251627ba12ab7510fbfdccefcd2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71/commits","review_comments_url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71/comments","review_comment_url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pipedrive/client-nodejs/issues/71/comments","statuses_url":"https://api.github.com/repos/pipedrive/client-nodejs/statuses/d1283871d98ec48274cb162d5cd674d54e486398","head":{"label":"TTU-Pipedrive:master","ref":"master","sha":"d1283871d98ec48274cb162d5cd674d54e486398","user":{"login":"TTU-Pipedrive","id":36964216,"avatar_url":"https://avatars1.githubusercontent.com/u/36964216?v=4","gravatar_id":"","url":"https://api.github.com/users/TTU-Pipedrive","html_url":"https://github.com/TTU-Pipedrive","followers_url":"https://api.github.com/users/TTU-Pipedrive/followers","following_url":"https://api.github.com/users/TTU-Pipedrive/following{/other_user}","gists_url":"https://api.github.com/users/TTU-Pipedrive/gists{/gist_id}","starred_url":"https://api.github.com/users/TTU-Pipedrive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TTU-Pipedrive/subscriptions","organizations_url":"https://api.github.com/users/TTU-Pipedrive/orgs","repos_url":"https://api.github.com/users/TTU-Pipedrive/repos","events_url":"https://api.github.com/users/TTU-Pipedrive/events{/privacy}","received_events_url":"https://api.github.com/users/TTU-Pipedrive/received_events","type":"Organization","site_admin":false},"repo":{"id":124767293,"name":"client-nodejs","full_name":"TTU-Pipedrive/client-nodejs","owner":{"login":"TTU-Pipedrive","id":36964216,"avatar_url":"https://avatars1.githubusercontent.com/u/36964216?v=4","gravatar_id":"","url":"https://api.github.com/users/TTU-Pipedrive","html_url":"https://github.com/TTU-Pipedrive","followers_url":"https://api.github.com/users/TTU-Pipedrive/followers","following_url":"https://api.github.com/users/TTU-Pipedrive/following{/other_user}","gists_url":"https://api.github.com/users/TTU-Pipedrive/gists{/gist_id}","starred_url":"https://api.github.com/users/TTU-Pipedrive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TTU-Pipedrive/subscriptions","organizations_url":"https://api.github.com/users/TTU-Pipedrive/orgs","repos_url":"https://api.github.com/users/TTU-Pipedrive/repos","events_url":"https://api.github.com/users/TTU-Pipedrive/events{/privacy}","received_events_url":"https://api.github.com/users/TTU-Pipedrive/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TTU-Pipedrive/client-nodejs","description":"Pipedrive API client for NodeJS","fork":true,"url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs","forks_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/forks","keys_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/teams","hooks_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/hooks","issue_events_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/events","assignees_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/tags","blobs_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/languages","stargazers_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/stargazers","contributors_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/contributors","subscribers_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/subscribers","subscription_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/subscription","commits_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/merges","archive_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/downloads","issues_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/releases{/id}","deployments_url":"https://api.github.com/repos/TTU-Pipedrive/client-nodejs/deployments","created_at":"2018-03-11T14:55:47Z","updated_at":"2018-05-06T13:30:20Z","pushed_at":"2018-05-06T13:30:18Z","git_url":"git://github.com/TTU-Pipedrive/client-nodejs.git","ssh_url":"git@github.com:TTU-Pipedrive/client-nodejs.git","clone_url":"https://github.com/TTU-Pipedrive/client-nodejs.git","svn_url":"https://github.com/TTU-Pipedrive/client-nodejs","homepage":null,"size":280,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pipedrive:master","ref":"master","sha":"0463c824b37d227118f0ff1d29520d5feb6f0c8c","user":{"login":"pipedrive","id":191836,"avatar_url":"https://avatars1.githubusercontent.com/u/191836?v=4","gravatar_id":"","url":"https://api.github.com/users/pipedrive","html_url":"https://github.com/pipedrive","followers_url":"https://api.github.com/users/pipedrive/followers","following_url":"https://api.github.com/users/pipedrive/following{/other_user}","gists_url":"https://api.github.com/users/pipedrive/gists{/gist_id}","starred_url":"https://api.github.com/users/pipedrive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipedrive/subscriptions","organizations_url":"https://api.github.com/users/pipedrive/orgs","repos_url":"https://api.github.com/users/pipedrive/repos","events_url":"https://api.github.com/users/pipedrive/events{/privacy}","received_events_url":"https://api.github.com/users/pipedrive/received_events","type":"Organization","site_admin":false},"repo":{"id":5019995,"name":"client-nodejs","full_name":"pipedrive/client-nodejs","owner":{"login":"pipedrive","id":191836,"avatar_url":"https://avatars1.githubusercontent.com/u/191836?v=4","gravatar_id":"","url":"https://api.github.com/users/pipedrive","html_url":"https://github.com/pipedrive","followers_url":"https://api.github.com/users/pipedrive/followers","following_url":"https://api.github.com/users/pipedrive/following{/other_user}","gists_url":"https://api.github.com/users/pipedrive/gists{/gist_id}","starred_url":"https://api.github.com/users/pipedrive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipedrive/subscriptions","organizations_url":"https://api.github.com/users/pipedrive/orgs","repos_url":"https://api.github.com/users/pipedrive/repos","events_url":"https://api.github.com/users/pipedrive/events{/privacy}","received_events_url":"https://api.github.com/users/pipedrive/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pipedrive/client-nodejs","description":"Pipedrive API client for NodeJS","fork":false,"url":"https://api.github.com/repos/pipedrive/client-nodejs","forks_url":"https://api.github.com/repos/pipedrive/client-nodejs/forks","keys_url":"https://api.github.com/repos/pipedrive/client-nodejs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pipedrive/client-nodejs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pipedrive/client-nodejs/teams","hooks_url":"https://api.github.com/repos/pipedrive/client-nodejs/hooks","issue_events_url":"https://api.github.com/repos/pipedrive/client-nodejs/issues/events{/number}","events_url":"https://api.github.com/repos/pipedrive/client-nodejs/events","assignees_url":"https://api.github.com/repos/pipedrive/client-nodejs/assignees{/user}","branches_url":"https://api.github.com/repos/pipedrive/client-nodejs/branches{/branch}","tags_url":"https://api.github.com/repos/pipedrive/client-nodejs/tags","blobs_url":"https://api.github.com/repos/pipedrive/client-nodejs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pipedrive/client-nodejs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pipedrive/client-nodejs/git/refs{/sha}","trees_url":"https://api.github.com/repos/pipedrive/client-nodejs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pipedrive/client-nodejs/statuses/{sha}","languages_url":"https://api.github.com/repos/pipedrive/client-nodejs/languages","stargazers_url":"https://api.github.com/repos/pipedrive/client-nodejs/stargazers","contributors_url":"https://api.github.com/repos/pipedrive/client-nodejs/contributors","subscribers_url":"https://api.github.com/repos/pipedrive/client-nodejs/subscribers","subscription_url":"https://api.github.com/repos/pipedrive/client-nodejs/subscription","commits_url":"https://api.github.com/repos/pipedrive/client-nodejs/commits{/sha}","git_commits_url":"https://api.github.com/repos/pipedrive/client-nodejs/git/commits{/sha}","comments_url":"https://api.github.com/repos/pipedrive/client-nodejs/comments{/number}","issue_comment_url":"https://api.github.com/repos/pipedrive/client-nodejs/issues/comments{/number}","contents_url":"https://api.github.com/repos/pipedrive/client-nodejs/contents/{+path}","compare_url":"https://api.github.com/repos/pipedrive/client-nodejs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pipedrive/client-nodejs/merges","archive_url":"https://api.github.com/repos/pipedrive/client-nodejs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pipedrive/client-nodejs/downloads","issues_url":"https://api.github.com/repos/pipedrive/client-nodejs/issues{/number}","pulls_url":"https://api.github.com/repos/pipedrive/client-nodejs/pulls{/number}","milestones_url":"https://api.github.com/repos/pipedrive/client-nodejs/milestones{/number}","notifications_url":"https://api.github.com/repos/pipedrive/client-nodejs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pipedrive/client-nodejs/labels{/name}","releases_url":"https://api.github.com/repos/pipedrive/client-nodejs/releases{/id}","deployments_url":"https://api.github.com/repos/pipedrive/client-nodejs/deployments","created_at":"2012-07-13T13:54:34Z","updated_at":"2018-05-05T17:02:51Z","pushed_at":"2018-05-06T13:30:20Z","git_url":"git://github.com/pipedrive/client-nodejs.git","ssh_url":"git@github.com:pipedrive/client-nodejs.git","clone_url":"https://github.com/pipedrive/client-nodejs.git","svn_url":"https://github.com/pipedrive/client-nodejs","homepage":null,"size":225,"stargazers_count":76,"watchers_count":76,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":34,"open_issues":15,"watchers":76,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71"},"html":{"href":"https://github.com/pipedrive/client-nodejs/pull/71"},"issue":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/issues/71"},"comments":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/pipedrive/client-nodejs/statuses/d1283871d98ec48274cb162d5cd674d54e486398"}},"author_association":"NONE"}}
{"actor":{"display_login":"deespater"}}