{"action":"created","comment":{"url":"https://api.github.com/repos/matobet/moVirt/pulls/comments/70089002","id":70089002,"diff_hunk":"@@ -682,6 +670,65 @@ public void setupVersionHeader() {\n         restClient.setHeader(\"Version\", authenticator.getApiMajorVersion());\n     }\n \n+    private void setPersistentV3AuthHeaders() {\n+        restClient.setHeader(SESSION_TTL, \"120\"); // 2h\n+        restClient.setHeader(PREFER, \"persistent-auth, csrf-protection\");\n+    }\n+\n+    private void resetClientSettings() {\n+        restClient.setHeader(SESSION_TTL, \"\");\n+        restClient.setHeader(PREFER, \"\");\n+        restClient.setCookie(JSESSIONID, \"\");\n+        restClient.setAuthentication(new HttpAuthentication() {\n+            @Override\n+            public String getHeaderValue() {\n+                // empty authentication - e.g. not the basic one\n+                return \"\";\n+            }\n+        });\n+    }\n+\n+    private void updateClientBeforeCall() {\n+        restClient.setHeader(FILTER, Boolean.toString(!authenticator.hasAdminPermissions()));\n+        requestFactory.setCertificateHandlingMode(authenticator.getCertHandlingStrategy());\n+        restClient.setRootUrl(authenticator.getApiUrl());\n+    }\n+\n+    /**\n+     * @param username username\n+     * @param password password\n+     * @return auth token depending on API version, if enforceBasicAuth is true then returns empty string\n+     */\n+    public String login(String username, String password) {\n+        resetClientSettings();\n+        updateClientBeforeCall();\n+        restClient.setHttpBasicAuth(username, password);\n+\n+        Api api = restClient.loginV3();","path":"moVirt/src/main/java/org/ovirt/mobile/movirt/rest/OVirtClient.java","position":478,"original_position":66,"commit_id":"da2df5ba43ad36987137d3e1ee73e1d7426d34c8","original_commit_id":"da2df5ba43ad36987137d3e1ee73e1d7426d34c8","user":{"login":"jelkosz","id":701107,"avatar_url":"https://avatars.githubusercontent.com/u/701107?v=3","gravatar_id":"","url":"https://api.github.com/users/jelkosz","html_url":"https://github.com/jelkosz","followers_url":"https://api.github.com/users/jelkosz/followers","following_url":"https://api.github.com/users/jelkosz/following{/other_user}","gists_url":"https://api.github.com/users/jelkosz/gists{/gist_id}","starred_url":"https://api.github.com/users/jelkosz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelkosz/subscriptions","organizations_url":"https://api.github.com/users/jelkosz/orgs","repos_url":"https://api.github.com/users/jelkosz/repos","events_url":"https://api.github.com/users/jelkosz/events{/privacy}","received_events_url":"https://api.github.com/users/jelkosz/received_events","type":"User","site_admin":false},"body":"@jhernand hi Juan, we are trying to make a detection of the API version here in order to know if we should work with v3 or v4. But in order to ask the api what version it is, we need to log in the old way (basic auth). Than, once we are logged in, we can find out we are working with the new API and login again using the oauth.\r\nIm not sure this is the intended use of the API. Is there a better way? Or, more importantly, will this even work after the v3 will be removed? :)","created_at":"2016-07-08T15:08:12Z","updated_at":"2016-07-08T15:08:12Z","html_url":"https://github.com/matobet/moVirt/pull/186#discussion_r70089002","pull_request_url":"https://api.github.com/repos/matobet/moVirt/pulls/186","_links":{"self":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/comments/70089002"},"html":{"href":"https://github.com/matobet/moVirt/pull/186#discussion_r70089002"},"pull_request":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/186"}}},"pull_request":{"url":"https://api.github.com/repos/matobet/moVirt/pulls/186","id":75038343,"html_url":"https://github.com/matobet/moVirt/pull/186","diff_url":"https://github.com/matobet/moVirt/pull/186.diff","patch_url":"https://github.com/matobet/moVirt/pull/186.patch","issue_url":"https://api.github.com/repos/matobet/moVirt/issues/186","number":186,"state":"open","locked":false,"title":"Api v4 support and SSO authorization ","user":{"login":"suomiy","id":3648838,"avatar_url":"https://avatars.githubusercontent.com/u/3648838?v=3","gravatar_id":"","url":"https://api.github.com/users/suomiy","html_url":"https://github.com/suomiy","followers_url":"https://api.github.com/users/suomiy/followers","following_url":"https://api.github.com/users/suomiy/following{/other_user}","gists_url":"https://api.github.com/users/suomiy/gists{/gist_id}","starred_url":"https://api.github.com/users/suomiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suomiy/subscriptions","organizations_url":"https://api.github.com/users/suomiy/orgs","repos_url":"https://api.github.com/users/suomiy/repos","events_url":"https://api.github.com/users/suomiy/events{/privacy}","received_events_url":"https://api.github.com/users/suomiy/received_events","type":"User","site_admin":false},"body":"\n\n<!-- Reviewable:start -->\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"35\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/matobet/movirt/186)\n<!-- Reviewable:end -->\n","created_at":"2016-06-23T22:31:45Z","updated_at":"2016-07-08T15:08:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f279b8fa44cf9207167d60089526e194a2e423a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/matobet/moVirt/pulls/186/commits","review_comments_url":"https://api.github.com/repos/matobet/moVirt/pulls/186/comments","review_comment_url":"https://api.github.com/repos/matobet/moVirt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matobet/moVirt/issues/186/comments","statuses_url":"https://api.github.com/repos/matobet/moVirt/statuses/da2df5ba43ad36987137d3e1ee73e1d7426d34c8","head":{"label":"suomiy:api4","ref":"api4","sha":"da2df5ba43ad36987137d3e1ee73e1d7426d34c8","user":{"login":"suomiy","id":3648838,"avatar_url":"https://avatars.githubusercontent.com/u/3648838?v=3","gravatar_id":"","url":"https://api.github.com/users/suomiy","html_url":"https://github.com/suomiy","followers_url":"https://api.github.com/users/suomiy/followers","following_url":"https://api.github.com/users/suomiy/following{/other_user}","gists_url":"https://api.github.com/users/suomiy/gists{/gist_id}","starred_url":"https://api.github.com/users/suomiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suomiy/subscriptions","organizations_url":"https://api.github.com/users/suomiy/orgs","repos_url":"https://api.github.com/users/suomiy/repos","events_url":"https://api.github.com/users/suomiy/events{/privacy}","received_events_url":"https://api.github.com/users/suomiy/received_events","type":"User","site_admin":false},"repo":{"id":45982599,"name":"moVirt","full_name":"suomiy/moVirt","owner":{"login":"suomiy","id":3648838,"avatar_url":"https://avatars.githubusercontent.com/u/3648838?v=3","gravatar_id":"","url":"https://api.github.com/users/suomiy","html_url":"https://github.com/suomiy","followers_url":"https://api.github.com/users/suomiy/followers","following_url":"https://api.github.com/users/suomiy/following{/other_user}","gists_url":"https://api.github.com/users/suomiy/gists{/gist_id}","starred_url":"https://api.github.com/users/suomiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suomiy/subscriptions","organizations_url":"https://api.github.com/users/suomiy/orgs","repos_url":"https://api.github.com/users/suomiy/repos","events_url":"https://api.github.com/users/suomiy/events{/privacy}","received_events_url":"https://api.github.com/users/suomiy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/suomiy/moVirt","description":"A mobile client for oVirt","fork":true,"url":"https://api.github.com/repos/suomiy/moVirt","forks_url":"https://api.github.com/repos/suomiy/moVirt/forks","keys_url":"https://api.github.com/repos/suomiy/moVirt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/suomiy/moVirt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/suomiy/moVirt/teams","hooks_url":"https://api.github.com/repos/suomiy/moVirt/hooks","issue_events_url":"https://api.github.com/repos/suomiy/moVirt/issues/events{/number}","events_url":"https://api.github.com/repos/suomiy/moVirt/events","assignees_url":"https://api.github.com/repos/suomiy/moVirt/assignees{/user}","branches_url":"https://api.github.com/repos/suomiy/moVirt/branches{/branch}","tags_url":"https://api.github.com/repos/suomiy/moVirt/tags","blobs_url":"https://api.github.com/repos/suomiy/moVirt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/suomiy/moVirt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/suomiy/moVirt/git/refs{/sha}","trees_url":"https://api.github.com/repos/suomiy/moVirt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/suomiy/moVirt/statuses/{sha}","languages_url":"https://api.github.com/repos/suomiy/moVirt/languages","stargazers_url":"https://api.github.com/repos/suomiy/moVirt/stargazers","contributors_url":"https://api.github.com/repos/suomiy/moVirt/contributors","subscribers_url":"https://api.github.com/repos/suomiy/moVirt/subscribers","subscription_url":"https://api.github.com/repos/suomiy/moVirt/subscription","commits_url":"https://api.github.com/repos/suomiy/moVirt/commits{/sha}","git_commits_url":"https://api.github.com/repos/suomiy/moVirt/git/commits{/sha}","comments_url":"https://api.github.com/repos/suomiy/moVirt/comments{/number}","issue_comment_url":"https://api.github.com/repos/suomiy/moVirt/issues/comments{/number}","contents_url":"https://api.github.com/repos/suomiy/moVirt/contents/{+path}","compare_url":"https://api.github.com/repos/suomiy/moVirt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/suomiy/moVirt/merges","archive_url":"https://api.github.com/repos/suomiy/moVirt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/suomiy/moVirt/downloads","issues_url":"https://api.github.com/repos/suomiy/moVirt/issues{/number}","pulls_url":"https://api.github.com/repos/suomiy/moVirt/pulls{/number}","milestones_url":"https://api.github.com/repos/suomiy/moVirt/milestones{/number}","notifications_url":"https://api.github.com/repos/suomiy/moVirt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/suomiy/moVirt/labels{/name}","releases_url":"https://api.github.com/repos/suomiy/moVirt/releases{/id}","deployments_url":"https://api.github.com/repos/suomiy/moVirt/deployments","created_at":"2015-11-11T13:13:56Z","updated_at":"2016-01-13T17:40:09Z","pushed_at":"2016-06-23T22:28:38Z","git_url":"git://github.com/suomiy/moVirt.git","ssh_url":"git@github.com:suomiy/moVirt.git","clone_url":"https://github.com/suomiy/moVirt.git","svn_url":"https://github.com/suomiy/moVirt","homepage":null,"size":55529,"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":"matobet:master","ref":"master","sha":"6ce3f2799218aa8217e65cf9f621c1826ee90bd3","user":{"login":"matobet","id":1173428,"avatar_url":"https://avatars.githubusercontent.com/u/1173428?v=3","gravatar_id":"","url":"https://api.github.com/users/matobet","html_url":"https://github.com/matobet","followers_url":"https://api.github.com/users/matobet/followers","following_url":"https://api.github.com/users/matobet/following{/other_user}","gists_url":"https://api.github.com/users/matobet/gists{/gist_id}","starred_url":"https://api.github.com/users/matobet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matobet/subscriptions","organizations_url":"https://api.github.com/users/matobet/orgs","repos_url":"https://api.github.com/users/matobet/repos","events_url":"https://api.github.com/users/matobet/events{/privacy}","received_events_url":"https://api.github.com/users/matobet/received_events","type":"User","site_admin":false},"repo":{"id":13483826,"name":"moVirt","full_name":"matobet/moVirt","owner":{"login":"matobet","id":1173428,"avatar_url":"https://avatars.githubusercontent.com/u/1173428?v=3","gravatar_id":"","url":"https://api.github.com/users/matobet","html_url":"https://github.com/matobet","followers_url":"https://api.github.com/users/matobet/followers","following_url":"https://api.github.com/users/matobet/following{/other_user}","gists_url":"https://api.github.com/users/matobet/gists{/gist_id}","starred_url":"https://api.github.com/users/matobet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matobet/subscriptions","organizations_url":"https://api.github.com/users/matobet/orgs","repos_url":"https://api.github.com/users/matobet/repos","events_url":"https://api.github.com/users/matobet/events{/privacy}","received_events_url":"https://api.github.com/users/matobet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matobet/moVirt","description":"A mobile client for oVirt","fork":false,"url":"https://api.github.com/repos/matobet/moVirt","forks_url":"https://api.github.com/repos/matobet/moVirt/forks","keys_url":"https://api.github.com/repos/matobet/moVirt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matobet/moVirt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matobet/moVirt/teams","hooks_url":"https://api.github.com/repos/matobet/moVirt/hooks","issue_events_url":"https://api.github.com/repos/matobet/moVirt/issues/events{/number}","events_url":"https://api.github.com/repos/matobet/moVirt/events","assignees_url":"https://api.github.com/repos/matobet/moVirt/assignees{/user}","branches_url":"https://api.github.com/repos/matobet/moVirt/branches{/branch}","tags_url":"https://api.github.com/repos/matobet/moVirt/tags","blobs_url":"https://api.github.com/repos/matobet/moVirt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matobet/moVirt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matobet/moVirt/git/refs{/sha}","trees_url":"https://api.github.com/repos/matobet/moVirt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matobet/moVirt/statuses/{sha}","languages_url":"https://api.github.com/repos/matobet/moVirt/languages","stargazers_url":"https://api.github.com/repos/matobet/moVirt/stargazers","contributors_url":"https://api.github.com/repos/matobet/moVirt/contributors","subscribers_url":"https://api.github.com/repos/matobet/moVirt/subscribers","subscription_url":"https://api.github.com/repos/matobet/moVirt/subscription","commits_url":"https://api.github.com/repos/matobet/moVirt/commits{/sha}","git_commits_url":"https://api.github.com/repos/matobet/moVirt/git/commits{/sha}","comments_url":"https://api.github.com/repos/matobet/moVirt/comments{/number}","issue_comment_url":"https://api.github.com/repos/matobet/moVirt/issues/comments{/number}","contents_url":"https://api.github.com/repos/matobet/moVirt/contents/{+path}","compare_url":"https://api.github.com/repos/matobet/moVirt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matobet/moVirt/merges","archive_url":"https://api.github.com/repos/matobet/moVirt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matobet/moVirt/downloads","issues_url":"https://api.github.com/repos/matobet/moVirt/issues{/number}","pulls_url":"https://api.github.com/repos/matobet/moVirt/pulls{/number}","milestones_url":"https://api.github.com/repos/matobet/moVirt/milestones{/number}","notifications_url":"https://api.github.com/repos/matobet/moVirt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matobet/moVirt/labels{/name}","releases_url":"https://api.github.com/repos/matobet/moVirt/releases{/id}","deployments_url":"https://api.github.com/repos/matobet/moVirt/deployments","created_at":"2013-10-10T21:49:01Z","updated_at":"2016-06-16T14:25:54Z","pushed_at":"2016-06-27T16:19:59Z","git_url":"git://github.com/matobet/moVirt.git","ssh_url":"git@github.com:matobet/moVirt.git","clone_url":"https://github.com/matobet/moVirt.git","svn_url":"https://github.com/matobet/moVirt","homepage":null,"size":55921,"stargazers_count":25,"watchers_count":25,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":22,"forks":17,"open_issues":22,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/186"},"html":{"href":"https://github.com/matobet/moVirt/pull/186"},"issue":{"href":"https://api.github.com/repos/matobet/moVirt/issues/186"},"comments":{"href":"https://api.github.com/repos/matobet/moVirt/issues/186/comments"},"review_comments":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/186/comments"},"review_comment":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matobet/moVirt/pulls/186/commits"},"statuses":{"href":"https://api.github.com/repos/matobet/moVirt/statuses/da2df5ba43ad36987137d3e1ee73e1d7426d34c8"}}}}
{"actor":{"display_login":"jelkosz"}}