{"action":"created","comment":{"url":"https://api.github.com/repos/asjoyner/shade/pulls/comments/83553481","pull_request_review_id":4390999,"id":83553481,"diff_hunk":"@@ -0,0 +1,99 @@\n+package google\n+\n+import (\n+\t\"context\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"log\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\n+\t\"github.com/asjoyner/shade\"\n+\t\"github.com/asjoyner/shade/drive\"\n+\n+\tgdrive \"google.golang.org/api/drive/v3\"\n+\n+\t\"golang.org/x/oauth2\"\n+)\n+\n+const (\n+\tclientID     = \"1060319012426-gb2f7picjh3dfsoni203rkmsjliqok1f.apps.googleusercontent.com\"\n+\tclientSecret = \"jfcCV2384sXBlqdaes26bAA5\"\n+\tauthURL      = \"https://accounts.google.com/o/oauth2/auth\"\n+\ttokenURL     = \"https://accounts.google.com/o/oauth2/token\"\n+\tredirectURI  = \"https://localhost\"\n+)\n+\n+var scope = []string{gdrive.DriveAppdataScope, gdrive.DriveFileScope}\n+\n+func getOAuthClient(c drive.Config) *http.Client {\n+\tconf := &oauth2.Config{\n+\t\tClientID:     clientID,\n+\t\tClientSecret: clientSecret,\n+\t\tScopes:       scope,\n+\t\tEndpoint: oauth2.Endpoint{\n+\t\t\tAuthURL:  authURL,\n+\t\t\tTokenURL: tokenURL,\n+\t\t},\n+\t\tRedirectURL: redirectURI,\n+\t}\n+\tif c.OAuth.ClientID != \"\" {\n+\t\tconf.ClientID = c.OAuth.ClientID\n+\t}\n+\tif c.OAuth.ClientSecret != \"\" {\n+\t\tconf.ClientSecret = c.OAuth.ClientSecret\n+\t}\n+\treturn getClient(context.TODO(), conf)\n+}\n+\n+func getClient(ctx context.Context, config *oauth2.Config) *http.Client {\n+\tcacheFile := filepath.Join(shade.ConfigDir(), \"google.token\")\n+\ttok, err := tokenFromFile(cacheFile)\n+\tif err != nil {\n+\t\ttok = fetchToken(config)\n+\t\tsaveToken(cacheFile, tok)\n+\t}\n+\treturn config.Client(ctx, tok)\n+}\n+\n+// fetchToken uses Config to request a Token.\n+func fetchToken(config *oauth2.Config) *oauth2.Token {\n+\tauthURL := config.AuthCodeURL(\"state-token\", oauth2.AccessTypeOffline)\n+\tfmt.Printf(\"Go to the following link in your browser then type the \"+\n+\t\t\"authorization code: \\n%v\\n\", authURL)\n+\n+\tvar code string\n+\tif _, err := fmt.Scan(&code); err != nil {","path":"drive/google/oauth.go","position":67,"original_position":67,"commit_id":"5be6fb38de966567f81af9e6e753f8802343fc7a","original_commit_id":"5be6fb38de966567f81af9e6e753f8802343fc7a","user":{"login":"cfunkhouser","id":2796783,"avatar_url":"https://avatars.githubusercontent.com/u/2796783?v=3","gravatar_id":"","url":"https://api.github.com/users/cfunkhouser","html_url":"https://github.com/cfunkhouser","followers_url":"https://api.github.com/users/cfunkhouser/followers","following_url":"https://api.github.com/users/cfunkhouser/following{/other_user}","gists_url":"https://api.github.com/users/cfunkhouser/gists{/gist_id}","starred_url":"https://api.github.com/users/cfunkhouser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfunkhouser/subscriptions","organizations_url":"https://api.github.com/users/cfunkhouser/orgs","repos_url":"https://api.github.com/users/cfunkhouser/repos","events_url":"https://api.github.com/users/cfunkhouser/events{/privacy}","received_events_url":"https://api.github.com/users/cfunkhouser/received_events","type":"User","site_admin":false},"body":"It's URI-encoded, so spaces will represented by \"%20\" or \"+\" in the code.","created_at":"2016-10-16T15:27:18Z","updated_at":"2016-10-16T15:27:18Z","html_url":"https://github.com/asjoyner/shade/pull/5#discussion_r83553481","pull_request_url":"https://api.github.com/repos/asjoyner/shade/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/comments/83553481"},"html":{"href":"https://github.com/asjoyner/shade/pull/5#discussion_r83553481"},"pull_request":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/asjoyner/shade/pulls/5","id":89451324,"html_url":"https://github.com/asjoyner/shade/pull/5","diff_url":"https://github.com/asjoyner/shade/pull/5.diff","patch_url":"https://github.com/asjoyner/shade/pull/5.patch","issue_url":"https://api.github.com/repos/asjoyner/shade/issues/5","number":5,"state":"open","locked":false,"title":"Google Drive Client implemention, first pass.","user":{"login":"cfunkhouser","id":2796783,"avatar_url":"https://avatars.githubusercontent.com/u/2796783?v=3","gravatar_id":"","url":"https://api.github.com/users/cfunkhouser","html_url":"https://github.com/cfunkhouser","followers_url":"https://api.github.com/users/cfunkhouser/followers","following_url":"https://api.github.com/users/cfunkhouser/following{/other_user}","gists_url":"https://api.github.com/users/cfunkhouser/gists{/gist_id}","starred_url":"https://api.github.com/users/cfunkhouser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfunkhouser/subscriptions","organizations_url":"https://api.github.com/users/cfunkhouser/orgs","repos_url":"https://api.github.com/users/cfunkhouser/repos","events_url":"https://api.github.com/users/cfunkhouser/events{/privacy}","received_events_url":"https://api.github.com/users/cfunkhouser/received_events","type":"User","site_admin":false},"body":"This implementation has worked for trivial writes and retrievals against Google Drive. Instead of using folders to organize the chunks, this implementation adds a \"shadeType\" AppProperty to the chunk file metadata on create, with possible values \"chunk\" or \"metadata,\" and filters on that during list operations.","created_at":"2016-10-14T20:41:50Z","updated_at":"2016-10-16T15:27:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fb94de3b9530bd555b5f997fb1fd179df3566d6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/asjoyner/shade/pulls/5/commits","review_comments_url":"https://api.github.com/repos/asjoyner/shade/pulls/5/comments","review_comment_url":"https://api.github.com/repos/asjoyner/shade/pulls/comments{/number}","comments_url":"https://api.github.com/repos/asjoyner/shade/issues/5/comments","statuses_url":"https://api.github.com/repos/asjoyner/shade/statuses/5be6fb38de966567f81af9e6e753f8802343fc7a","head":{"label":"cfunkhouser:master","ref":"master","sha":"5be6fb38de966567f81af9e6e753f8802343fc7a","user":{"login":"cfunkhouser","id":2796783,"avatar_url":"https://avatars.githubusercontent.com/u/2796783?v=3","gravatar_id":"","url":"https://api.github.com/users/cfunkhouser","html_url":"https://github.com/cfunkhouser","followers_url":"https://api.github.com/users/cfunkhouser/followers","following_url":"https://api.github.com/users/cfunkhouser/following{/other_user}","gists_url":"https://api.github.com/users/cfunkhouser/gists{/gist_id}","starred_url":"https://api.github.com/users/cfunkhouser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfunkhouser/subscriptions","organizations_url":"https://api.github.com/users/cfunkhouser/orgs","repos_url":"https://api.github.com/users/cfunkhouser/repos","events_url":"https://api.github.com/users/cfunkhouser/events{/privacy}","received_events_url":"https://api.github.com/users/cfunkhouser/received_events","type":"User","site_admin":false},"repo":{"id":63160423,"name":"shade","full_name":"cfunkhouser/shade","owner":{"login":"cfunkhouser","id":2796783,"avatar_url":"https://avatars.githubusercontent.com/u/2796783?v=3","gravatar_id":"","url":"https://api.github.com/users/cfunkhouser","html_url":"https://github.com/cfunkhouser","followers_url":"https://api.github.com/users/cfunkhouser/followers","following_url":"https://api.github.com/users/cfunkhouser/following{/other_user}","gists_url":"https://api.github.com/users/cfunkhouser/gists{/gist_id}","starred_url":"https://api.github.com/users/cfunkhouser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfunkhouser/subscriptions","organizations_url":"https://api.github.com/users/cfunkhouser/orgs","repos_url":"https://api.github.com/users/cfunkhouser/repos","events_url":"https://api.github.com/users/cfunkhouser/events{/privacy}","received_events_url":"https://api.github.com/users/cfunkhouser/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cfunkhouser/shade","description":"SHA Drive Engine stores files in the cloud, in a flexible fashion, optionally encrypted.","fork":true,"url":"https://api.github.com/repos/cfunkhouser/shade","forks_url":"https://api.github.com/repos/cfunkhouser/shade/forks","keys_url":"https://api.github.com/repos/cfunkhouser/shade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfunkhouser/shade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfunkhouser/shade/teams","hooks_url":"https://api.github.com/repos/cfunkhouser/shade/hooks","issue_events_url":"https://api.github.com/repos/cfunkhouser/shade/issues/events{/number}","events_url":"https://api.github.com/repos/cfunkhouser/shade/events","assignees_url":"https://api.github.com/repos/cfunkhouser/shade/assignees{/user}","branches_url":"https://api.github.com/repos/cfunkhouser/shade/branches{/branch}","tags_url":"https://api.github.com/repos/cfunkhouser/shade/tags","blobs_url":"https://api.github.com/repos/cfunkhouser/shade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfunkhouser/shade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfunkhouser/shade/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfunkhouser/shade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfunkhouser/shade/statuses/{sha}","languages_url":"https://api.github.com/repos/cfunkhouser/shade/languages","stargazers_url":"https://api.github.com/repos/cfunkhouser/shade/stargazers","contributors_url":"https://api.github.com/repos/cfunkhouser/shade/contributors","subscribers_url":"https://api.github.com/repos/cfunkhouser/shade/subscribers","subscription_url":"https://api.github.com/repos/cfunkhouser/shade/subscription","commits_url":"https://api.github.com/repos/cfunkhouser/shade/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfunkhouser/shade/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfunkhouser/shade/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfunkhouser/shade/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfunkhouser/shade/contents/{+path}","compare_url":"https://api.github.com/repos/cfunkhouser/shade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfunkhouser/shade/merges","archive_url":"https://api.github.com/repos/cfunkhouser/shade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfunkhouser/shade/downloads","issues_url":"https://api.github.com/repos/cfunkhouser/shade/issues{/number}","pulls_url":"https://api.github.com/repos/cfunkhouser/shade/pulls{/number}","milestones_url":"https://api.github.com/repos/cfunkhouser/shade/milestones{/number}","notifications_url":"https://api.github.com/repos/cfunkhouser/shade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfunkhouser/shade/labels{/name}","releases_url":"https://api.github.com/repos/cfunkhouser/shade/releases{/id}","deployments_url":"https://api.github.com/repos/cfunkhouser/shade/deployments","created_at":"2016-07-12T13:31:28Z","updated_at":"2016-07-12T13:31:29Z","pushed_at":"2016-10-14T20:34:55Z","git_url":"git://github.com/cfunkhouser/shade.git","ssh_url":"git@github.com:cfunkhouser/shade.git","clone_url":"https://github.com/cfunkhouser/shade.git","svn_url":"https://github.com/cfunkhouser/shade","homepage":null,"size":168,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"asjoyner:master","ref":"master","sha":"d0a234f8effe71a7f4119d72acc9f16decd769c3","user":{"login":"asjoyner","id":1161025,"avatar_url":"https://avatars.githubusercontent.com/u/1161025?v=3","gravatar_id":"","url":"https://api.github.com/users/asjoyner","html_url":"https://github.com/asjoyner","followers_url":"https://api.github.com/users/asjoyner/followers","following_url":"https://api.github.com/users/asjoyner/following{/other_user}","gists_url":"https://api.github.com/users/asjoyner/gists{/gist_id}","starred_url":"https://api.github.com/users/asjoyner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asjoyner/subscriptions","organizations_url":"https://api.github.com/users/asjoyner/orgs","repos_url":"https://api.github.com/users/asjoyner/repos","events_url":"https://api.github.com/users/asjoyner/events{/privacy}","received_events_url":"https://api.github.com/users/asjoyner/received_events","type":"User","site_admin":false},"repo":{"id":60429459,"name":"shade","full_name":"asjoyner/shade","owner":{"login":"asjoyner","id":1161025,"avatar_url":"https://avatars.githubusercontent.com/u/1161025?v=3","gravatar_id":"","url":"https://api.github.com/users/asjoyner","html_url":"https://github.com/asjoyner","followers_url":"https://api.github.com/users/asjoyner/followers","following_url":"https://api.github.com/users/asjoyner/following{/other_user}","gists_url":"https://api.github.com/users/asjoyner/gists{/gist_id}","starred_url":"https://api.github.com/users/asjoyner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asjoyner/subscriptions","organizations_url":"https://api.github.com/users/asjoyner/orgs","repos_url":"https://api.github.com/users/asjoyner/repos","events_url":"https://api.github.com/users/asjoyner/events{/privacy}","received_events_url":"https://api.github.com/users/asjoyner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asjoyner/shade","description":"SHA Drive Engine stores files in the cloud, in a flexible fashion, optionally encrypted.","fork":false,"url":"https://api.github.com/repos/asjoyner/shade","forks_url":"https://api.github.com/repos/asjoyner/shade/forks","keys_url":"https://api.github.com/repos/asjoyner/shade/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asjoyner/shade/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asjoyner/shade/teams","hooks_url":"https://api.github.com/repos/asjoyner/shade/hooks","issue_events_url":"https://api.github.com/repos/asjoyner/shade/issues/events{/number}","events_url":"https://api.github.com/repos/asjoyner/shade/events","assignees_url":"https://api.github.com/repos/asjoyner/shade/assignees{/user}","branches_url":"https://api.github.com/repos/asjoyner/shade/branches{/branch}","tags_url":"https://api.github.com/repos/asjoyner/shade/tags","blobs_url":"https://api.github.com/repos/asjoyner/shade/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asjoyner/shade/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asjoyner/shade/git/refs{/sha}","trees_url":"https://api.github.com/repos/asjoyner/shade/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asjoyner/shade/statuses/{sha}","languages_url":"https://api.github.com/repos/asjoyner/shade/languages","stargazers_url":"https://api.github.com/repos/asjoyner/shade/stargazers","contributors_url":"https://api.github.com/repos/asjoyner/shade/contributors","subscribers_url":"https://api.github.com/repos/asjoyner/shade/subscribers","subscription_url":"https://api.github.com/repos/asjoyner/shade/subscription","commits_url":"https://api.github.com/repos/asjoyner/shade/commits{/sha}","git_commits_url":"https://api.github.com/repos/asjoyner/shade/git/commits{/sha}","comments_url":"https://api.github.com/repos/asjoyner/shade/comments{/number}","issue_comment_url":"https://api.github.com/repos/asjoyner/shade/issues/comments{/number}","contents_url":"https://api.github.com/repos/asjoyner/shade/contents/{+path}","compare_url":"https://api.github.com/repos/asjoyner/shade/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asjoyner/shade/merges","archive_url":"https://api.github.com/repos/asjoyner/shade/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asjoyner/shade/downloads","issues_url":"https://api.github.com/repos/asjoyner/shade/issues{/number}","pulls_url":"https://api.github.com/repos/asjoyner/shade/pulls{/number}","milestones_url":"https://api.github.com/repos/asjoyner/shade/milestones{/number}","notifications_url":"https://api.github.com/repos/asjoyner/shade/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asjoyner/shade/labels{/name}","releases_url":"https://api.github.com/repos/asjoyner/shade/releases{/id}","deployments_url":"https://api.github.com/repos/asjoyner/shade/deployments","created_at":"2016-06-04T20:41:58Z","updated_at":"2016-08-27T01:35:52Z","pushed_at":"2016-10-14T20:41:50Z","git_url":"git://github.com/asjoyner/shade.git","ssh_url":"git@github.com:asjoyner/shade.git","clone_url":"https://github.com/asjoyner/shade.git","svn_url":"https://github.com/asjoyner/shade","homepage":null,"size":159,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/5"},"html":{"href":"https://github.com/asjoyner/shade/pull/5"},"issue":{"href":"https://api.github.com/repos/asjoyner/shade/issues/5"},"comments":{"href":"https://api.github.com/repos/asjoyner/shade/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/asjoyner/shade/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/asjoyner/shade/statuses/5be6fb38de966567f81af9e6e753f8802343fc7a"}}}}
{"actor":{"display_login":"cfunkhouser"}}