{"action":"created","comment":{"url":"https://api.github.com/repos/allegro/hermes/pulls/comments/63025446","id":63025446,"diff_hunk":"@@ -0,0 +1,65 @@\n+package pl.allegro.tech.hermes.consumers.consumer.sender.http;\n+\n+import pl.allegro.tech.hermes.api.OAuth2AuthenticationData;\n+import pl.allegro.tech.hermes.api.Subscription;\n+import pl.allegro.tech.hermes.common.cache.zookeeper.NodeCache;\n+import pl.allegro.tech.hermes.consumers.consumer.ConsumerMessageSender;\n+import pl.allegro.tech.hermes.consumers.consumer.Message;\n+\n+import com.github.scribejava.core.builder.api.DefaultApi20;\n+\n+import com.github.scribejava.core.builder.ServiceBuilder;\n+import com.github.scribejava.core.model.OAuth2AccessToken;\n+import com.github.scribejava.core.oauth.OAuth20Service;\n+import com.github.scribejava.core.model.OAuthConfig;\n+\n+public class OAuth2AuthProvider implements HttpAuthorizationProvider {\n+\n+    private final OAuth2AuthenticationData authData;\n+\n+    private final OAuth20Service service;\n+\n+    private String accessToken;\n+\n+    public OAuth2AuthProvider(Subscription subscription) {\n+        this.authData = subscription.getOAuth2AuthenticationData();\n+\n+        service = new ServiceBuilder()\n+                .apiKey(authData.getConsumerKey())\n+                .apiSecret(authData.getConsumerSecret())\n+                .build(new OAuthApi(authData.getAccessTokenEndpoint()));\n+        obtainAccessToken();\n+    }\n+\n+    @Override\n+    public String authorizationToken(Message message) {\n+        if (message.getNumberOfUnauthorizedRequests() == 1) {","path":"hermes-consumers/src/main/java/pl/allegro/tech/hermes/consumers/consumer/sender/http/OAuth2AuthProvider.java","position":36,"original_position":36,"commit_id":"d913e30212e2f65634d7e10089d64db75200e616","original_commit_id":"d913e30212e2f65634d7e10089d64db75200e616","user":{"login":"adamdubiel","id":5269406,"avatar_url":"https://avatars.githubusercontent.com/u/5269406?v=3","gravatar_id":"","url":"https://api.github.com/users/adamdubiel","html_url":"https://github.com/adamdubiel","followers_url":"https://api.github.com/users/adamdubiel/followers","following_url":"https://api.github.com/users/adamdubiel/following{/other_user}","gists_url":"https://api.github.com/users/adamdubiel/gists{/gist_id}","starred_url":"https://api.github.com/users/adamdubiel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamdubiel/subscriptions","organizations_url":"https://api.github.com/users/adamdubiel/orgs","repos_url":"https://api.github.com/users/adamdubiel/repos","events_url":"https://api.github.com/users/adamdubiel/events{/privacy}","received_events_url":"https://api.github.com/users/adamdubiel/received_events","type":"User","site_admin":false},"body":"i think setting this to 1 might be dangerous - why 1? is it not to repeat authorization if it fails once? what if i have 10 msgs and all came back unathorized (in parallel) - do you want to send separate requests for all of them?","created_at":"2016-05-12T14:03:59Z","updated_at":"2016-05-12T14:03:59Z","html_url":"https://github.com/allegro/hermes/pull/484#discussion_r63025446","pull_request_url":"https://api.github.com/repos/allegro/hermes/pulls/484","_links":{"self":{"href":"https://api.github.com/repos/allegro/hermes/pulls/comments/63025446"},"html":{"href":"https://github.com/allegro/hermes/pull/484#discussion_r63025446"},"pull_request":{"href":"https://api.github.com/repos/allegro/hermes/pulls/484"}}},"pull_request":{"url":"https://api.github.com/repos/allegro/hermes/pulls/484","id":69837274,"html_url":"https://github.com/allegro/hermes/pull/484","diff_url":"https://github.com/allegro/hermes/pull/484.diff","patch_url":"https://github.com/allegro/hermes/pull/484.patch","issue_url":"https://api.github.com/repos/allegro/hermes/issues/484","number":484,"state":"open","locked":false,"title":"359 oauth2","user":{"login":"Saal89","id":19188267,"avatar_url":"https://avatars.githubusercontent.com/u/19188267?v=3","gravatar_id":"","url":"https://api.github.com/users/Saal89","html_url":"https://github.com/Saal89","followers_url":"https://api.github.com/users/Saal89/followers","following_url":"https://api.github.com/users/Saal89/following{/other_user}","gists_url":"https://api.github.com/users/Saal89/gists{/gist_id}","starred_url":"https://api.github.com/users/Saal89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Saal89/subscriptions","organizations_url":"https://api.github.com/users/Saal89/orgs","repos_url":"https://api.github.com/users/Saal89/repos","events_url":"https://api.github.com/users/Saal89/events{/privacy}","received_events_url":"https://api.github.com/users/Saal89/received_events","type":"User","site_admin":false},"body":"Czekam jeszcze na https://github.com/scribejava/scribejava/pull/659. Jak na razie spreparowany jar jest w folderze hermes-consumers","created_at":"2016-05-12T13:36:06Z","updated_at":"2016-05-12T14:03:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1478ba69f399abeec4ee6c79a4ce7f4e431f16b5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/allegro/hermes/pulls/484/commits","review_comments_url":"https://api.github.com/repos/allegro/hermes/pulls/484/comments","review_comment_url":"https://api.github.com/repos/allegro/hermes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allegro/hermes/issues/484/comments","statuses_url":"https://api.github.com/repos/allegro/hermes/statuses/d913e30212e2f65634d7e10089d64db75200e616","head":{"label":"Saal89:359_oauth2","ref":"359_oauth2","sha":"d913e30212e2f65634d7e10089d64db75200e616","user":{"login":"Saal89","id":19188267,"avatar_url":"https://avatars.githubusercontent.com/u/19188267?v=3","gravatar_id":"","url":"https://api.github.com/users/Saal89","html_url":"https://github.com/Saal89","followers_url":"https://api.github.com/users/Saal89/followers","following_url":"https://api.github.com/users/Saal89/following{/other_user}","gists_url":"https://api.github.com/users/Saal89/gists{/gist_id}","starred_url":"https://api.github.com/users/Saal89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Saal89/subscriptions","organizations_url":"https://api.github.com/users/Saal89/orgs","repos_url":"https://api.github.com/users/Saal89/repos","events_url":"https://api.github.com/users/Saal89/events{/privacy}","received_events_url":"https://api.github.com/users/Saal89/received_events","type":"User","site_admin":false},"repo":{"id":58626496,"name":"hermes","full_name":"Saal89/hermes","owner":{"login":"Saal89","id":19188267,"avatar_url":"https://avatars.githubusercontent.com/u/19188267?v=3","gravatar_id":"","url":"https://api.github.com/users/Saal89","html_url":"https://github.com/Saal89","followers_url":"https://api.github.com/users/Saal89/followers","following_url":"https://api.github.com/users/Saal89/following{/other_user}","gists_url":"https://api.github.com/users/Saal89/gists{/gist_id}","starred_url":"https://api.github.com/users/Saal89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Saal89/subscriptions","organizations_url":"https://api.github.com/users/Saal89/orgs","repos_url":"https://api.github.com/users/Saal89/repos","events_url":"https://api.github.com/users/Saal89/events{/privacy}","received_events_url":"https://api.github.com/users/Saal89/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Saal89/hermes","description":"Fast and reliable message broker built on top of Kafka.","fork":true,"url":"https://api.github.com/repos/Saal89/hermes","forks_url":"https://api.github.com/repos/Saal89/hermes/forks","keys_url":"https://api.github.com/repos/Saal89/hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Saal89/hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Saal89/hermes/teams","hooks_url":"https://api.github.com/repos/Saal89/hermes/hooks","issue_events_url":"https://api.github.com/repos/Saal89/hermes/issues/events{/number}","events_url":"https://api.github.com/repos/Saal89/hermes/events","assignees_url":"https://api.github.com/repos/Saal89/hermes/assignees{/user}","branches_url":"https://api.github.com/repos/Saal89/hermes/branches{/branch}","tags_url":"https://api.github.com/repos/Saal89/hermes/tags","blobs_url":"https://api.github.com/repos/Saal89/hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Saal89/hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Saal89/hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/Saal89/hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Saal89/hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/Saal89/hermes/languages","stargazers_url":"https://api.github.com/repos/Saal89/hermes/stargazers","contributors_url":"https://api.github.com/repos/Saal89/hermes/contributors","subscribers_url":"https://api.github.com/repos/Saal89/hermes/subscribers","subscription_url":"https://api.github.com/repos/Saal89/hermes/subscription","commits_url":"https://api.github.com/repos/Saal89/hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/Saal89/hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/Saal89/hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/Saal89/hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/Saal89/hermes/contents/{+path}","compare_url":"https://api.github.com/repos/Saal89/hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Saal89/hermes/merges","archive_url":"https://api.github.com/repos/Saal89/hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Saal89/hermes/downloads","issues_url":"https://api.github.com/repos/Saal89/hermes/issues{/number}","pulls_url":"https://api.github.com/repos/Saal89/hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/Saal89/hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/Saal89/hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Saal89/hermes/labels{/name}","releases_url":"https://api.github.com/repos/Saal89/hermes/releases{/id}","deployments_url":"https://api.github.com/repos/Saal89/hermes/deployments","created_at":"2016-05-12T09:13:53Z","updated_at":"2016-05-12T09:13:55Z","pushed_at":"2016-05-12T13:34:00Z","git_url":"git://github.com/Saal89/hermes.git","ssh_url":"git@github.com:Saal89/hermes.git","clone_url":"https://github.com/Saal89/hermes.git","svn_url":"https://github.com/Saal89/hermes","homepage":"http://hermes.allegro.tech","size":4478,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"allegro:develop","ref":"develop","sha":"8038fe6d49d95958242375356d24d9e44b133144","user":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"repo":{"id":35662043,"name":"hermes","full_name":"allegro/hermes","owner":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=3","gravatar_id":"","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allegro/hermes","description":"Fast and reliable message broker built on top of Kafka.","fork":false,"url":"https://api.github.com/repos/allegro/hermes","forks_url":"https://api.github.com/repos/allegro/hermes/forks","keys_url":"https://api.github.com/repos/allegro/hermes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allegro/hermes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allegro/hermes/teams","hooks_url":"https://api.github.com/repos/allegro/hermes/hooks","issue_events_url":"https://api.github.com/repos/allegro/hermes/issues/events{/number}","events_url":"https://api.github.com/repos/allegro/hermes/events","assignees_url":"https://api.github.com/repos/allegro/hermes/assignees{/user}","branches_url":"https://api.github.com/repos/allegro/hermes/branches{/branch}","tags_url":"https://api.github.com/repos/allegro/hermes/tags","blobs_url":"https://api.github.com/repos/allegro/hermes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allegro/hermes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allegro/hermes/git/refs{/sha}","trees_url":"https://api.github.com/repos/allegro/hermes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allegro/hermes/statuses/{sha}","languages_url":"https://api.github.com/repos/allegro/hermes/languages","stargazers_url":"https://api.github.com/repos/allegro/hermes/stargazers","contributors_url":"https://api.github.com/repos/allegro/hermes/contributors","subscribers_url":"https://api.github.com/repos/allegro/hermes/subscribers","subscription_url":"https://api.github.com/repos/allegro/hermes/subscription","commits_url":"https://api.github.com/repos/allegro/hermes/commits{/sha}","git_commits_url":"https://api.github.com/repos/allegro/hermes/git/commits{/sha}","comments_url":"https://api.github.com/repos/allegro/hermes/comments{/number}","issue_comment_url":"https://api.github.com/repos/allegro/hermes/issues/comments{/number}","contents_url":"https://api.github.com/repos/allegro/hermes/contents/{+path}","compare_url":"https://api.github.com/repos/allegro/hermes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allegro/hermes/merges","archive_url":"https://api.github.com/repos/allegro/hermes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allegro/hermes/downloads","issues_url":"https://api.github.com/repos/allegro/hermes/issues{/number}","pulls_url":"https://api.github.com/repos/allegro/hermes/pulls{/number}","milestones_url":"https://api.github.com/repos/allegro/hermes/milestones{/number}","notifications_url":"https://api.github.com/repos/allegro/hermes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allegro/hermes/labels{/name}","releases_url":"https://api.github.com/repos/allegro/hermes/releases{/id}","deployments_url":"https://api.github.com/repos/allegro/hermes/deployments","created_at":"2015-05-15T08:11:16Z","updated_at":"2016-05-04T10:02:35Z","pushed_at":"2016-05-12T13:36:06Z","git_url":"git://github.com/allegro/hermes.git","ssh_url":"git@github.com:allegro/hermes.git","clone_url":"https://github.com/allegro/hermes.git","svn_url":"https://github.com/allegro/hermes","homepage":"http://hermes.allegro.tech","size":4655,"stargazers_count":176,"watchers_count":176,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":32,"forks":34,"open_issues":32,"watchers":176,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/allegro/hermes/pulls/484"},"html":{"href":"https://github.com/allegro/hermes/pull/484"},"issue":{"href":"https://api.github.com/repos/allegro/hermes/issues/484"},"comments":{"href":"https://api.github.com/repos/allegro/hermes/issues/484/comments"},"review_comments":{"href":"https://api.github.com/repos/allegro/hermes/pulls/484/comments"},"review_comment":{"href":"https://api.github.com/repos/allegro/hermes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allegro/hermes/pulls/484/commits"},"statuses":{"href":"https://api.github.com/repos/allegro/hermes/statuses/d913e30212e2f65634d7e10089d64db75200e616"}}}}