{"action":"created","comment":{"url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/comments/64147167","id":64147167,"diff_hunk":"@@ -0,0 +1,39 @@\n+package io.github.codeocean_scraper\n+\n+import org.jsoup.Connection\n+import org.jsoup.Jsoup\n+import java.net.URL\n+\n+private fun login(baseUrl: URL, email: String, password: String): String {\n+    val loginUrl = URL(baseUrl, \"/sign_in\")\n+    val pageResponse = Jsoup.connect(loginUrl.toString())\n+                            .method(Connection.Method.GET)\n+                            .execute()\n+    val doc = pageResponse.parse()\n+    val token = doc.select(\"input[name=\\\"authenticity_token\\\"]\").first().`val`()\n+    val formData = mapOf(\n+            \"utf-8\" to \"✓\",\n+            \"authenticity_token\" to token,\n+            \"email\" to email,\n+            \"password\" to password,\n+            \"commit\" to \"Sign+In\"\n+    )\n+    val loginResponse = Jsoup.connect(URL(baseUrl, \"/sessions\").toString())\n+                             .method(Connection.Method.POST)\n+                             .data(formData)\n+                             .cookies(pageResponse.cookies())\n+                             .execute()\n+    return loginResponse.cookie(\"_hands-on-programming_session\")\n+}\n+\n+fun interactiveLogin(baseUrl: URL): String {\n+    val console = System.console()\n+    if (console == null) {\n+        System.err.println(\"Can't get console object to read email and password. Aborting!\")\n+        System.exit(1)\n+    }\n+\n+    val email = console.readLine(\"Email: \")\n+    val password = String(console.readPassword(\"Password: \"))","path":"src/main/kotlin/io/github/codeocean_scraper/Login.kt","position":37,"original_position":37,"commit_id":"50f8283e32d28a24db0829841ac7525da2ef7cc9","original_commit_id":"50f8283e32d28a24db0829841ac7525da2ef7cc9","user":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"body":"Because we give the password to JSoup, we can't really control where it is stored anyway.","created_at":"2016-05-22T09:43:52Z","updated_at":"2016-05-22T09:43:52Z","html_url":"https://github.com/Felerius/codeocean-scraper/pull/7#discussion_r64147167","pull_request_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/comments/64147167"},"html":{"href":"https://github.com/Felerius/codeocean-scraper/pull/7#discussion_r64147167"},"pull_request":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7","id":70956092,"html_url":"https://github.com/Felerius/codeocean-scraper/pull/7","diff_url":"https://github.com/Felerius/codeocean-scraper/pull/7.diff","patch_url":"https://github.com/Felerius/codeocean-scraper/pull/7.patch","issue_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/7","number":7,"state":"open","locked":false,"title":"Enable login with the cli while caching session keys","user":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"body":"Alleviates the need to extract the session cookie from a browser. Session keys are cached in `~/.codeocean-scraper.json`, one per base CodeOcean url. The user is requested to enter an email plus password when no session key has been cached, or the cached one has been invalidated.\r\n\r\nI also upgraded Kotlin to version 1.0.2, because I was hitting a compiler bug of version 1.0.1-2 in the process. The new version also enables incremental compilation for gradle, to speed up compiling.","created_at":"2016-05-21T18:02:11Z","updated_at":"2016-05-22T09:43:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"12730a1242693ca827d0667d4d7ce0dd01621b6c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7/commits","review_comments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7/comments","review_comment_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/7/comments","statuses_url":"https://api.github.com/repos/Felerius/codeocean-scraper/statuses/50f8283e32d28a24db0829841ac7525da2ef7cc9","head":{"label":"Felerius:login","ref":"login","sha":"50f8283e32d28a24db0829841ac7525da2ef7cc9","user":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"repo":{"id":57923051,"name":"codeocean-scraper","full_name":"Felerius/codeocean-scraper","owner":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Felerius/codeocean-scraper","description":"Batch download student submission from CodeOcean","fork":false,"url":"https://api.github.com/repos/Felerius/codeocean-scraper","forks_url":"https://api.github.com/repos/Felerius/codeocean-scraper/forks","keys_url":"https://api.github.com/repos/Felerius/codeocean-scraper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Felerius/codeocean-scraper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Felerius/codeocean-scraper/teams","hooks_url":"https://api.github.com/repos/Felerius/codeocean-scraper/hooks","issue_events_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/events{/number}","events_url":"https://api.github.com/repos/Felerius/codeocean-scraper/events","assignees_url":"https://api.github.com/repos/Felerius/codeocean-scraper/assignees{/user}","branches_url":"https://api.github.com/repos/Felerius/codeocean-scraper/branches{/branch}","tags_url":"https://api.github.com/repos/Felerius/codeocean-scraper/tags","blobs_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/refs{/sha}","trees_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Felerius/codeocean-scraper/statuses/{sha}","languages_url":"https://api.github.com/repos/Felerius/codeocean-scraper/languages","stargazers_url":"https://api.github.com/repos/Felerius/codeocean-scraper/stargazers","contributors_url":"https://api.github.com/repos/Felerius/codeocean-scraper/contributors","subscribers_url":"https://api.github.com/repos/Felerius/codeocean-scraper/subscribers","subscription_url":"https://api.github.com/repos/Felerius/codeocean-scraper/subscription","commits_url":"https://api.github.com/repos/Felerius/codeocean-scraper/commits{/sha}","git_commits_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/commits{/sha}","comments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/comments{/number}","issue_comment_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/comments{/number}","contents_url":"https://api.github.com/repos/Felerius/codeocean-scraper/contents/{+path}","compare_url":"https://api.github.com/repos/Felerius/codeocean-scraper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Felerius/codeocean-scraper/merges","archive_url":"https://api.github.com/repos/Felerius/codeocean-scraper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Felerius/codeocean-scraper/downloads","issues_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues{/number}","pulls_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls{/number}","milestones_url":"https://api.github.com/repos/Felerius/codeocean-scraper/milestones{/number}","notifications_url":"https://api.github.com/repos/Felerius/codeocean-scraper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Felerius/codeocean-scraper/labels{/name}","releases_url":"https://api.github.com/repos/Felerius/codeocean-scraper/releases{/id}","deployments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/deployments","created_at":"2016-05-02T21:37:45Z","updated_at":"2016-05-04T12:15:59Z","pushed_at":"2016-05-22T09:29:45Z","git_url":"git://github.com/Felerius/codeocean-scraper.git","ssh_url":"git@github.com:Felerius/codeocean-scraper.git","clone_url":"https://github.com/Felerius/codeocean-scraper.git","svn_url":"https://github.com/Felerius/codeocean-scraper","homepage":"","size":76,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Felerius:master","ref":"master","sha":"81bac4936ad19247b759c60b1cf982b012820b4a","user":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"repo":{"id":57923051,"name":"codeocean-scraper","full_name":"Felerius/codeocean-scraper","owner":{"login":"Felerius","id":9287484,"avatar_url":"https://avatars.githubusercontent.com/u/9287484?v=3","gravatar_id":"","url":"https://api.github.com/users/Felerius","html_url":"https://github.com/Felerius","followers_url":"https://api.github.com/users/Felerius/followers","following_url":"https://api.github.com/users/Felerius/following{/other_user}","gists_url":"https://api.github.com/users/Felerius/gists{/gist_id}","starred_url":"https://api.github.com/users/Felerius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Felerius/subscriptions","organizations_url":"https://api.github.com/users/Felerius/orgs","repos_url":"https://api.github.com/users/Felerius/repos","events_url":"https://api.github.com/users/Felerius/events{/privacy}","received_events_url":"https://api.github.com/users/Felerius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Felerius/codeocean-scraper","description":"Batch download student submission from CodeOcean","fork":false,"url":"https://api.github.com/repos/Felerius/codeocean-scraper","forks_url":"https://api.github.com/repos/Felerius/codeocean-scraper/forks","keys_url":"https://api.github.com/repos/Felerius/codeocean-scraper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Felerius/codeocean-scraper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Felerius/codeocean-scraper/teams","hooks_url":"https://api.github.com/repos/Felerius/codeocean-scraper/hooks","issue_events_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/events{/number}","events_url":"https://api.github.com/repos/Felerius/codeocean-scraper/events","assignees_url":"https://api.github.com/repos/Felerius/codeocean-scraper/assignees{/user}","branches_url":"https://api.github.com/repos/Felerius/codeocean-scraper/branches{/branch}","tags_url":"https://api.github.com/repos/Felerius/codeocean-scraper/tags","blobs_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/refs{/sha}","trees_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Felerius/codeocean-scraper/statuses/{sha}","languages_url":"https://api.github.com/repos/Felerius/codeocean-scraper/languages","stargazers_url":"https://api.github.com/repos/Felerius/codeocean-scraper/stargazers","contributors_url":"https://api.github.com/repos/Felerius/codeocean-scraper/contributors","subscribers_url":"https://api.github.com/repos/Felerius/codeocean-scraper/subscribers","subscription_url":"https://api.github.com/repos/Felerius/codeocean-scraper/subscription","commits_url":"https://api.github.com/repos/Felerius/codeocean-scraper/commits{/sha}","git_commits_url":"https://api.github.com/repos/Felerius/codeocean-scraper/git/commits{/sha}","comments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/comments{/number}","issue_comment_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/comments{/number}","contents_url":"https://api.github.com/repos/Felerius/codeocean-scraper/contents/{+path}","compare_url":"https://api.github.com/repos/Felerius/codeocean-scraper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Felerius/codeocean-scraper/merges","archive_url":"https://api.github.com/repos/Felerius/codeocean-scraper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Felerius/codeocean-scraper/downloads","issues_url":"https://api.github.com/repos/Felerius/codeocean-scraper/issues{/number}","pulls_url":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls{/number}","milestones_url":"https://api.github.com/repos/Felerius/codeocean-scraper/milestones{/number}","notifications_url":"https://api.github.com/repos/Felerius/codeocean-scraper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Felerius/codeocean-scraper/labels{/name}","releases_url":"https://api.github.com/repos/Felerius/codeocean-scraper/releases{/id}","deployments_url":"https://api.github.com/repos/Felerius/codeocean-scraper/deployments","created_at":"2016-05-02T21:37:45Z","updated_at":"2016-05-04T12:15:59Z","pushed_at":"2016-05-22T09:29:45Z","git_url":"git://github.com/Felerius/codeocean-scraper.git","ssh_url":"git@github.com:Felerius/codeocean-scraper.git","clone_url":"https://github.com/Felerius/codeocean-scraper.git","svn_url":"https://github.com/Felerius/codeocean-scraper","homepage":"","size":76,"stargazers_count":0,"watchers_count":0,"language":"Kotlin","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7"},"html":{"href":"https://github.com/Felerius/codeocean-scraper/pull/7"},"issue":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/7"},"comments":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/Felerius/codeocean-scraper/statuses/50f8283e32d28a24db0829841ac7525da2ef7cc9"}}}}
{"actor":{"display_login":"Felerius"}}