{"action":"created","comment":{"url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/comments/35249503","id":35249503,"diff_hunk":"@@ -42,55 +47,76 @@ var util = require('util')\n  */\n function Strategy(options, verify) {\n   options = options || {};\n-  options.requestTokenURL = options.requestTokenURL || 'https://bitbucket.org/api/1.0/oauth/request_token/';\n-  options.accessTokenURL = options.accessTokenURL || 'https://bitbucket.org/api/1.0/oauth/access_token/';\n-  options.userAuthorizationURL = options.userAuthorizationURL || 'https://bitbucket.org/api/1.0/oauth/authenticate/';\n-  options.sessionKey = options.sessionKey || 'oauth:bitbucket';\n+  options.authorizationURL = options.authorizationURL || 'https://bitbucket.org/site/oauth2/authorize';\n+  options.tokenURL = options.tokenURL || 'https://bitbucket.org/site/oauth2/access_token';\n+  options.customHeaders = options.customHeaders || {};\n \n-  OAuthStrategy.call(this, options, verify);\n+  //HACK: swap for OAuth2 property\n+  if (options.consumerKey && !options.clientID) {\n+    options.clientID = options.consumerKey;\n+  }\n+\n+  //HACK: swap for OAuth2 property\n+  if (options.consumerSecret && !options.clientSecret) {\n+    options.clientSecret = options.consumerSecret;\n+  }\n+\n+  if (!options.customHeaders['User-Agent']) {\n+    options.customHeaders['User-Agent'] = options.userAgent || 'passport-bitbucket';\n+    //HACK: requests need to fall back to Basic Auth (for access_token call)\n+    options.customHeaders.Authorization = 'Basic ' + new Buffer(options.clientID + ':' + options.clientSecret).toString('base64');\n+  }\n+\n+  OAuth2Strategy.call(this, options, verify);\n   this.name = 'bitbucket';\n+  this._userProfileURL = options.userProfileURL || 'https://bitbucket.org/api/2.0/user';\n+  this._oauth2.useAuthorizationHeaderforGET(true);\n+  console.log(this);","path":"lib/passport-bitbucket/strategy.js","position":null,"original_position":84,"commit_id":"63b001fe5e4965a86c826ed1c41eb59f61cfb8cc","original_commit_id":"0cff7c1a45672c5595a8a70699e0eec47ef68a39","user":{"login":"gtanner","id":317051,"avatar_url":"https://avatars.githubusercontent.com/u/317051?v=3","gravatar_id":"","url":"https://api.github.com/users/gtanner","html_url":"https://github.com/gtanner","followers_url":"https://api.github.com/users/gtanner/followers","following_url":"https://api.github.com/users/gtanner/following{/other_user}","gists_url":"https://api.github.com/users/gtanner/gists{/gist_id}","starred_url":"https://api.github.com/users/gtanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtanner/subscriptions","organizations_url":"https://api.github.com/users/gtanner/orgs","repos_url":"https://api.github.com/users/gtanner/repos","events_url":"https://api.github.com/users/gtanner/events{/privacy}","received_events_url":"https://api.github.com/users/gtanner/received_events","type":"User","site_admin":false},"body":"thanks! removed","created_at":"2015-07-22T18:53:26Z","updated_at":"2015-07-22T18:53:26Z","html_url":"https://github.com/jaredhanson/passport-bitbucket/pull/4#discussion_r35249503","pull_request_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/comments/35249503"},"html":{"href":"https://github.com/jaredhanson/passport-bitbucket/pull/4#discussion_r35249503"},"pull_request":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4","id":40532376,"html_url":"https://github.com/jaredhanson/passport-bitbucket/pull/4","diff_url":"https://github.com/jaredhanson/passport-bitbucket/pull/4.diff","patch_url":"https://github.com/jaredhanson/passport-bitbucket/pull/4.patch","issue_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/4","number":4,"state":"open","locked":false,"title":"Update to use the OAuth 2.0 APIs","user":{"login":"gtanner","id":317051,"avatar_url":"https://avatars.githubusercontent.com/u/317051?v=3","gravatar_id":"","url":"https://api.github.com/users/gtanner","html_url":"https://github.com/gtanner","followers_url":"https://api.github.com/users/gtanner/followers","following_url":"https://api.github.com/users/gtanner/following{/other_user}","gists_url":"https://api.github.com/users/gtanner/gists{/gist_id}","starred_url":"https://api.github.com/users/gtanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtanner/subscriptions","organizations_url":"https://api.github.com/users/gtanner/orgs","repos_url":"https://api.github.com/users/gtanner/repos","events_url":"https://api.github.com/users/gtanner/events{/privacy}","received_events_url":"https://api.github.com/users/gtanner/received_events","type":"User","site_admin":false},"body":"This will still work for https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket#OAuthonBitbucket-OAuth2.0.\r\n\r\nShould be an easy upgrade since the original params will still work, but the arguments to the callback function have changed (to the OAuth2 variant).\r\n\r\nWill need a semver version bump to indicate the change.","created_at":"2015-07-22T05:52:12Z","updated_at":"2015-07-22T18:53:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d55f5eebb5666408f86de8b8f7ec9ba9f90367bb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4/commits","review_comments_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4/comments","review_comment_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/4/comments","statuses_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/statuses/63b001fe5e4965a86c826ed1c41eb59f61cfb8cc","head":{"label":"bithound:master","ref":"master","sha":"63b001fe5e4965a86c826ed1c41eb59f61cfb8cc","user":{"login":"bithound","id":5826309,"avatar_url":"https://avatars.githubusercontent.com/u/5826309?v=3","gravatar_id":"","url":"https://api.github.com/users/bithound","html_url":"https://github.com/bithound","followers_url":"https://api.github.com/users/bithound/followers","following_url":"https://api.github.com/users/bithound/following{/other_user}","gists_url":"https://api.github.com/users/bithound/gists{/gist_id}","starred_url":"https://api.github.com/users/bithound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bithound/subscriptions","organizations_url":"https://api.github.com/users/bithound/orgs","repos_url":"https://api.github.com/users/bithound/repos","events_url":"https://api.github.com/users/bithound/events{/privacy}","received_events_url":"https://api.github.com/users/bithound/received_events","type":"Organization","site_admin":false},"repo":{"id":39485390,"name":"passport-bitbucket","full_name":"bithound/passport-bitbucket","owner":{"login":"bithound","id":5826309,"avatar_url":"https://avatars.githubusercontent.com/u/5826309?v=3","gravatar_id":"","url":"https://api.github.com/users/bithound","html_url":"https://github.com/bithound","followers_url":"https://api.github.com/users/bithound/followers","following_url":"https://api.github.com/users/bithound/following{/other_user}","gists_url":"https://api.github.com/users/bithound/gists{/gist_id}","starred_url":"https://api.github.com/users/bithound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bithound/subscriptions","organizations_url":"https://api.github.com/users/bithound/orgs","repos_url":"https://api.github.com/users/bithound/repos","events_url":"https://api.github.com/users/bithound/events{/privacy}","received_events_url":"https://api.github.com/users/bithound/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bithound/passport-bitbucket","description":"Bitbucket authentication strategy for Passport and Node.js.","fork":true,"url":"https://api.github.com/repos/bithound/passport-bitbucket","forks_url":"https://api.github.com/repos/bithound/passport-bitbucket/forks","keys_url":"https://api.github.com/repos/bithound/passport-bitbucket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bithound/passport-bitbucket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bithound/passport-bitbucket/teams","hooks_url":"https://api.github.com/repos/bithound/passport-bitbucket/hooks","issue_events_url":"https://api.github.com/repos/bithound/passport-bitbucket/issues/events{/number}","events_url":"https://api.github.com/repos/bithound/passport-bitbucket/events","assignees_url":"https://api.github.com/repos/bithound/passport-bitbucket/assignees{/user}","branches_url":"https://api.github.com/repos/bithound/passport-bitbucket/branches{/branch}","tags_url":"https://api.github.com/repos/bithound/passport-bitbucket/tags","blobs_url":"https://api.github.com/repos/bithound/passport-bitbucket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bithound/passport-bitbucket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bithound/passport-bitbucket/git/refs{/sha}","trees_url":"https://api.github.com/repos/bithound/passport-bitbucket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bithound/passport-bitbucket/statuses/{sha}","languages_url":"https://api.github.com/repos/bithound/passport-bitbucket/languages","stargazers_url":"https://api.github.com/repos/bithound/passport-bitbucket/stargazers","contributors_url":"https://api.github.com/repos/bithound/passport-bitbucket/contributors","subscribers_url":"https://api.github.com/repos/bithound/passport-bitbucket/subscribers","subscription_url":"https://api.github.com/repos/bithound/passport-bitbucket/subscription","commits_url":"https://api.github.com/repos/bithound/passport-bitbucket/commits{/sha}","git_commits_url":"https://api.github.com/repos/bithound/passport-bitbucket/git/commits{/sha}","comments_url":"https://api.github.com/repos/bithound/passport-bitbucket/comments{/number}","issue_comment_url":"https://api.github.com/repos/bithound/passport-bitbucket/issues/comments{/number}","contents_url":"https://api.github.com/repos/bithound/passport-bitbucket/contents/{+path}","compare_url":"https://api.github.com/repos/bithound/passport-bitbucket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bithound/passport-bitbucket/merges","archive_url":"https://api.github.com/repos/bithound/passport-bitbucket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bithound/passport-bitbucket/downloads","issues_url":"https://api.github.com/repos/bithound/passport-bitbucket/issues{/number}","pulls_url":"https://api.github.com/repos/bithound/passport-bitbucket/pulls{/number}","milestones_url":"https://api.github.com/repos/bithound/passport-bitbucket/milestones{/number}","notifications_url":"https://api.github.com/repos/bithound/passport-bitbucket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bithound/passport-bitbucket/labels{/name}","releases_url":"https://api.github.com/repos/bithound/passport-bitbucket/releases{/id}","created_at":"2015-07-22T04:23:20Z","updated_at":"2015-07-22T04:23:20Z","pushed_at":"2015-07-22T18:52:38Z","git_url":"git://github.com/bithound/passport-bitbucket.git","ssh_url":"git@github.com:bithound/passport-bitbucket.git","clone_url":"https://github.com/bithound/passport-bitbucket.git","svn_url":"https://github.com/bithound/passport-bitbucket","homepage":"","size":98,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"jaredhanson:master","ref":"master","sha":"34a60d5a26d0a566cc15db03fc2ca9ac41df02fc","user":{"login":"jaredhanson","id":10355,"avatar_url":"https://avatars.githubusercontent.com/u/10355?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredhanson","html_url":"https://github.com/jaredhanson","followers_url":"https://api.github.com/users/jaredhanson/followers","following_url":"https://api.github.com/users/jaredhanson/following{/other_user}","gists_url":"https://api.github.com/users/jaredhanson/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredhanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredhanson/subscriptions","organizations_url":"https://api.github.com/users/jaredhanson/orgs","repos_url":"https://api.github.com/users/jaredhanson/repos","events_url":"https://api.github.com/users/jaredhanson/events{/privacy}","received_events_url":"https://api.github.com/users/jaredhanson/received_events","type":"User","site_admin":false},"repo":{"id":3160903,"name":"passport-bitbucket","full_name":"jaredhanson/passport-bitbucket","owner":{"login":"jaredhanson","id":10355,"avatar_url":"https://avatars.githubusercontent.com/u/10355?v=3","gravatar_id":"","url":"https://api.github.com/users/jaredhanson","html_url":"https://github.com/jaredhanson","followers_url":"https://api.github.com/users/jaredhanson/followers","following_url":"https://api.github.com/users/jaredhanson/following{/other_user}","gists_url":"https://api.github.com/users/jaredhanson/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredhanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredhanson/subscriptions","organizations_url":"https://api.github.com/users/jaredhanson/orgs","repos_url":"https://api.github.com/users/jaredhanson/repos","events_url":"https://api.github.com/users/jaredhanson/events{/privacy}","received_events_url":"https://api.github.com/users/jaredhanson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jaredhanson/passport-bitbucket","description":"Bitbucket authentication strategy for Passport and Node.js.","fork":false,"url":"https://api.github.com/repos/jaredhanson/passport-bitbucket","forks_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/forks","keys_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/teams","hooks_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/hooks","issue_events_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/events{/number}","events_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/events","assignees_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/assignees{/user}","branches_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/branches{/branch}","tags_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/tags","blobs_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/git/refs{/sha}","trees_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/statuses/{sha}","languages_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/languages","stargazers_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/stargazers","contributors_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/contributors","subscribers_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/subscribers","subscription_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/subscription","commits_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/commits{/sha}","git_commits_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/git/commits{/sha}","comments_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/comments{/number}","issue_comment_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/comments{/number}","contents_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/contents/{+path}","compare_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/merges","archive_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/downloads","issues_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues{/number}","pulls_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls{/number}","milestones_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/milestones{/number}","notifications_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/labels{/name}","releases_url":"https://api.github.com/repos/jaredhanson/passport-bitbucket/releases{/id}","created_at":"2012-01-12T09:07:04Z","updated_at":"2015-05-29T11:26:31Z","pushed_at":"2015-07-22T18:52:39Z","git_url":"git://github.com/jaredhanson/passport-bitbucket.git","ssh_url":"git@github.com:jaredhanson/passport-bitbucket.git","clone_url":"https://github.com/jaredhanson/passport-bitbucket.git","svn_url":"https://github.com/jaredhanson/passport-bitbucket","homepage":"","size":291,"stargazers_count":12,"watchers_count":12,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":3,"forks":10,"open_issues":3,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4"},"html":{"href":"https://github.com/jaredhanson/passport-bitbucket/pull/4"},"issue":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/4"},"comments":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/jaredhanson/passport-bitbucket/statuses/63b001fe5e4965a86c826ed1c41eb59f61cfb8cc"}}}}