{"action":"created","comment":{"url":"https://api.github.com/repos/looker/actions/pulls/comments/259157301","pull_request_review_id":206591553,"id":259157301,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1OTE1NzMwMQ==","diff_hunk":"@@ -0,0 +1,211 @@\n+import * as querystring from \"querystring\"\n+import * as https from \"request-promise-native\"\n+import {URL} from \"url\"\n+\n+import Dropbox = require(\"dropbox\")\n+import * as winston from \"winston\"\n+import * as Hub from \"../../hub\"\n+\n+export class DropboxAction extends Hub.OAuthAction {\n+    name = \"dropbox\"\n+    label = \"Dropbox\"\n+    iconName = \"dropbox/dropbox.png\"\n+    description = \"Send query results directly to a file in your Dropbox.\"\n+    supportedActionTypes = [Hub.ActionType.Query, Hub.ActionType.Dashboard]\n+    usesStreaming = false\n+    minimumSupportedLookerVersion = \"6.4.0\"\n+    requiredFields = []\n+    params = [\n+      {\n+        description: \"Dropbox Application Key\",\n+        label: \"Application Key\",\n+        name: \"appKey\",\n+        required: true,\n+        sensitive: true,\n+      },\n+      {\n+        description: \"Dropbox Secret Key\",\n+        label: \"Secret Key\",\n+        name: \"secretKey\",\n+        required: true,\n+        sensitive: true,\n+      },\n+    ]\n+\n+  async execute(request: Hub.ActionRequest) {\n+    const filename = request.formParams.filename\n+    const directory = request.formParams.directory\n+    const ext = request.attachment!.fileExtension\n+\n+    let accessToken = \"\"\n+    if (request.params.state_json) {\n+      const jsonState = JSON.parse(request.params.state_json)\n+      if (jsonState.code && jsonState.redirect) {\n+        accessToken = await this.getAccessTokenFromCode(request)\n+      }\n+    }\n+    const drop = this.dropboxClientFromRequest(request, accessToken)\n+\n+    const resp = new Hub.ActionResponse()\n+    if (request.attachment && request.attachment.dataBuffer) {\n+      const fileBuf = request.attachment.dataBuffer\n+      await drop.filesUpload({path: `/${directory}/${filename}.${ext}`, contents: fileBuf}).then((_dropResp) => {\n+        resp.success = true\n+        resp.state = new Hub.ActionState()\n+        resp.state.data = \"reset\"\n+      }).catch((err: any) => {\n+        winston.error(`Upload unsuccessful: ${JSON.stringify(err)}`)\n+        resp.success = false\n+        resp.state = new Hub.ActionState()\n+        resp.state.data = \"reset\"\n+      })\n+    } else {\n+      resp.success = false\n+      resp.message = \"No data sent from Looker to be sent to Dropbox\"\n+    }\n+    return resp\n+  }\n+\n+  async form(request: Hub.ActionRequest) {\n+    const form = new Hub.ActionForm()\n+    form.fields = []\n+\n+    let accessToken = \"\"\n+    if (request.params.state_json) {\n+      try {\n+        const jsonState = JSON.parse(request.params.state_json)\n+        if (jsonState.code && jsonState.redirect) {\n+          accessToken = await this.getAccessTokenFromCode(request)\n+        }\n+      } catch { winston.warn(request.params.state_json) }\n+    }\n+    const drop = this.dropboxClientFromRequest(request, accessToken)\n+    return new Promise<Hub.ActionForm>((resolve, reject) => {\n+      drop.filesListFolder({path: \"\"})\n+        .then((resp) => {\n+          form.fields = [{\n+            description: \"Dropbox directory where file will be saved\",\n+            label: \"Save in\",\n+            name: \"directory\",\n+            options: resp.entries.map((entries) => ({name: entries.name, label: entries.name})),\n+            required: true,\n+            type: \"select\",\n+          }, {\n+            label: \"Filename\",\n+            name: \"filename\",\n+            type: \"string\",\n+          }]\n+          if (accessToken !== \"\") {\n+            const newState = JSON.stringify({access_token: accessToken})\n+            form.state = new Hub.ActionState()\n+            form.state.data = newState\n+          } else {\n+            form.state = new Hub.ActionState()\n+          }\n+          resolve(form)\n+        })\n+        .catch((_error: DropboxTypes.Error<DropboxTypes.files.ListFolderError>) => {\n+          winston.info(\"Could not list Dropbox folders\")\n+          const actionCrypto = new Hub.ActionCrypto()\n+          const jsonString = JSON.stringify({stateurl: request.params.state_url, app: request.params.appKey})\n+          actionCrypto.encrypt(jsonString).then((ciphertextBlob: string) => {\n+            form.state = new Hub.ActionState()\n+            form.fields.push({\n+              name: \"login\",\n+              type: \"oauth_link\",\n+              label: \"Log in with Dropbox\",\n+              oauth_url: `${process.env.ACTION_HUB_BASE_URL}/actions/dropbox/oauth?state=${ciphertextBlob}`,\n+            })\n+            resolve(form)\n+          }).catch((err: string) => {\n+            winston.error(\"Encryption not correctly configured\")\n+            reject(err)\n+          })\n+        })\n+    })\n+  }\n+  // async oauthUrl(redirectUri: string, stateUrl: string, encryptedState) {\n+  async oauthUrl(redirectUri: string, encryptedState: string) {\n+    const url = new URL(\"https://www.dropbox.com/oauth2/authorize\")\n+    const actionCrypto = new Hub.ActionCrypto()\n+    const decryptedState = await actionCrypto.decrypt(encryptedState).catch((reason: any) => {\n+      throw reason","path":"src/actions/dropbox/dropbox.ts","position":128,"original_position":132,"commit_id":"98155e6dac2ba53c644d494cded8a6eaaae2bfb8","original_commit_id":"303ce11de2b6511cd9d771c591f98413ed68e0c6","user":{"login":"JimRottinger","id":32466096,"node_id":"MDQ6VXNlcjMyNDY2MDk2","avatar_url":"https://avatars2.githubusercontent.com/u/32466096?v=4","gravatar_id":"","url":"https://api.github.com/users/JimRottinger","html_url":"https://github.com/JimRottinger","followers_url":"https://api.github.com/users/JimRottinger/followers","following_url":"https://api.github.com/users/JimRottinger/following{/other_user}","gists_url":"https://api.github.com/users/JimRottinger/gists{/gist_id}","starred_url":"https://api.github.com/users/JimRottinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimRottinger/subscriptions","organizations_url":"https://api.github.com/users/JimRottinger/orgs","repos_url":"https://api.github.com/users/JimRottinger/repos","events_url":"https://api.github.com/users/JimRottinger/events{/privacy}","received_events_url":"https://api.github.com/users/JimRottinger/received_events","type":"User","site_admin":false},"body":"I'm guessing the linter requires the catch? That would be my guess but Wil is right that this is just catching and throwing immediately","created_at":"2019-02-21T23:18:27Z","updated_at":"2019-02-21T23:18:27Z","html_url":"https://github.com/looker/actions/pull/219#discussion_r259157301","pull_request_url":"https://api.github.com/repos/looker/actions/pulls/219","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/looker/actions/pulls/comments/259157301"},"html":{"href":"https://github.com/looker/actions/pull/219#discussion_r259157301"},"pull_request":{"href":"https://api.github.com/repos/looker/actions/pulls/219"}},"in_reply_to_id":259117814},"pull_request":{"url":"https://api.github.com/repos/looker/actions/pulls/219","id":227016499,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MDE2NDk5","html_url":"https://github.com/looker/actions/pull/219","diff_url":"https://github.com/looker/actions/pull/219.diff","patch_url":"https://github.com/looker/actions/pull/219.patch","issue_url":"https://api.github.com/repos/looker/actions/issues/219","number":219,"state":"open","locked":false,"title":"OAuth Framework and Dropbox","user":{"login":"phillipperalez","id":14983122,"node_id":"MDQ6VXNlcjE0OTgzMTIy","avatar_url":"https://avatars3.githubusercontent.com/u/14983122?v=4","gravatar_id":"","url":"https://api.github.com/users/phillipperalez","html_url":"https://github.com/phillipperalez","followers_url":"https://api.github.com/users/phillipperalez/followers","following_url":"https://api.github.com/users/phillipperalez/following{/other_user}","gists_url":"https://api.github.com/users/phillipperalez/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipperalez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipperalez/subscriptions","organizations_url":"https://api.github.com/users/phillipperalez/orgs","repos_url":"https://api.github.com/users/phillipperalez/repos","events_url":"https://api.github.com/users/phillipperalez/events{/privacy}","received_events_url":"https://api.github.com/users/phillipperalez/received_events","type":"User","site_admin":false},"body":"Adding the necessary framework to add Oauth enabled actions to the ActionHub","created_at":"2018-10-30T17:34:52Z","updated_at":"2019-02-21T23:18:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"762e94ba58d65b0b8531b46b47bc9c16fa8a740f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"JimRottinger","id":32466096,"node_id":"MDQ6VXNlcjMyNDY2MDk2","avatar_url":"https://avatars2.githubusercontent.com/u/32466096?v=4","gravatar_id":"","url":"https://api.github.com/users/JimRottinger","html_url":"https://github.com/JimRottinger","followers_url":"https://api.github.com/users/JimRottinger/followers","following_url":"https://api.github.com/users/JimRottinger/following{/other_user}","gists_url":"https://api.github.com/users/JimRottinger/gists{/gist_id}","starred_url":"https://api.github.com/users/JimRottinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimRottinger/subscriptions","organizations_url":"https://api.github.com/users/JimRottinger/orgs","repos_url":"https://api.github.com/users/JimRottinger/repos","events_url":"https://api.github.com/users/JimRottinger/events{/privacy}","received_events_url":"https://api.github.com/users/JimRottinger/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/looker/actions/pulls/219/commits","review_comments_url":"https://api.github.com/repos/looker/actions/pulls/219/comments","review_comment_url":"https://api.github.com/repos/looker/actions/pulls/comments{/number}","comments_url":"https://api.github.com/repos/looker/actions/issues/219/comments","statuses_url":"https://api.github.com/repos/looker/actions/statuses/98155e6dac2ba53c644d494cded8a6eaaae2bfb8","head":{"label":"looker:oauth-phillip","ref":"oauth-phillip","sha":"98155e6dac2ba53c644d494cded8a6eaaae2bfb8","user":{"login":"looker","id":1437874,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzc4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1437874?v=4","gravatar_id":"","url":"https://api.github.com/users/looker","html_url":"https://github.com/looker","followers_url":"https://api.github.com/users/looker/followers","following_url":"https://api.github.com/users/looker/following{/other_user}","gists_url":"https://api.github.com/users/looker/gists{/gist_id}","starred_url":"https://api.github.com/users/looker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/looker/subscriptions","organizations_url":"https://api.github.com/users/looker/orgs","repos_url":"https://api.github.com/users/looker/repos","events_url":"https://api.github.com/users/looker/events{/privacy}","received_events_url":"https://api.github.com/users/looker/received_events","type":"Organization","site_admin":false},"repo":{"id":87483460,"node_id":"MDEwOlJlcG9zaXRvcnk4NzQ4MzQ2MA==","name":"actions","full_name":"looker/actions","private":false,"owner":{"login":"looker","id":1437874,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzc4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1437874?v=4","gravatar_id":"","url":"https://api.github.com/users/looker","html_url":"https://github.com/looker","followers_url":"https://api.github.com/users/looker/followers","following_url":"https://api.github.com/users/looker/following{/other_user}","gists_url":"https://api.github.com/users/looker/gists{/gist_id}","starred_url":"https://api.github.com/users/looker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/looker/subscriptions","organizations_url":"https://api.github.com/users/looker/orgs","repos_url":"https://api.github.com/users/looker/repos","events_url":"https://api.github.com/users/looker/events{/privacy}","received_events_url":"https://api.github.com/users/looker/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/looker/actions","description":null,"fork":false,"url":"https://api.github.com/repos/looker/actions","forks_url":"https://api.github.com/repos/looker/actions/forks","keys_url":"https://api.github.com/repos/looker/actions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/looker/actions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/looker/actions/teams","hooks_url":"https://api.github.com/repos/looker/actions/hooks","issue_events_url":"https://api.github.com/repos/looker/actions/issues/events{/number}","events_url":"https://api.github.com/repos/looker/actions/events","assignees_url":"https://api.github.com/repos/looker/actions/assignees{/user}","branches_url":"https://api.github.com/repos/looker/actions/branches{/branch}","tags_url":"https://api.github.com/repos/looker/actions/tags","blobs_url":"https://api.github.com/repos/looker/actions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/looker/actions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/looker/actions/git/refs{/sha}","trees_url":"https://api.github.com/repos/looker/actions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/looker/actions/statuses/{sha}","languages_url":"https://api.github.com/repos/looker/actions/languages","stargazers_url":"https://api.github.com/repos/looker/actions/stargazers","contributors_url":"https://api.github.com/repos/looker/actions/contributors","subscribers_url":"https://api.github.com/repos/looker/actions/subscribers","subscription_url":"https://api.github.com/repos/looker/actions/subscription","commits_url":"https://api.github.com/repos/looker/actions/commits{/sha}","git_commits_url":"https://api.github.com/repos/looker/actions/git/commits{/sha}","comments_url":"https://api.github.com/repos/looker/actions/comments{/number}","issue_comment_url":"https://api.github.com/repos/looker/actions/issues/comments{/number}","contents_url":"https://api.github.com/repos/looker/actions/contents/{+path}","compare_url":"https://api.github.com/repos/looker/actions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/looker/actions/merges","archive_url":"https://api.github.com/repos/looker/actions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/looker/actions/downloads","issues_url":"https://api.github.com/repos/looker/actions/issues{/number}","pulls_url":"https://api.github.com/repos/looker/actions/pulls{/number}","milestones_url":"https://api.github.com/repos/looker/actions/milestones{/number}","notifications_url":"https://api.github.com/repos/looker/actions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/looker/actions/labels{/name}","releases_url":"https://api.github.com/repos/looker/actions/releases{/id}","deployments_url":"https://api.github.com/repos/looker/actions/deployments","created_at":"2017-04-06T23:15:13Z","updated_at":"2019-02-20T20:47:39Z","pushed_at":"2019-02-21T22:49:01Z","git_url":"git://github.com/looker/actions.git","ssh_url":"git@github.com:looker/actions.git","clone_url":"https://github.com/looker/actions.git","svn_url":"https://github.com/looker/actions","homepage":null,"size":17397,"stargazers_count":7,"watchers_count":7,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":37,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14,"open_issues":37,"watchers":7,"default_branch":"master"}},"base":{"label":"looker:master","ref":"master","sha":"5ff7632181543e232e1a0d17c0385538ae1d7525","user":{"login":"looker","id":1437874,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzc4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1437874?v=4","gravatar_id":"","url":"https://api.github.com/users/looker","html_url":"https://github.com/looker","followers_url":"https://api.github.com/users/looker/followers","following_url":"https://api.github.com/users/looker/following{/other_user}","gists_url":"https://api.github.com/users/looker/gists{/gist_id}","starred_url":"https://api.github.com/users/looker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/looker/subscriptions","organizations_url":"https://api.github.com/users/looker/orgs","repos_url":"https://api.github.com/users/looker/repos","events_url":"https://api.github.com/users/looker/events{/privacy}","received_events_url":"https://api.github.com/users/looker/received_events","type":"Organization","site_admin":false},"repo":{"id":87483460,"node_id":"MDEwOlJlcG9zaXRvcnk4NzQ4MzQ2MA==","name":"actions","full_name":"looker/actions","private":false,"owner":{"login":"looker","id":1437874,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0Mzc4NzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1437874?v=4","gravatar_id":"","url":"https://api.github.com/users/looker","html_url":"https://github.com/looker","followers_url":"https://api.github.com/users/looker/followers","following_url":"https://api.github.com/users/looker/following{/other_user}","gists_url":"https://api.github.com/users/looker/gists{/gist_id}","starred_url":"https://api.github.com/users/looker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/looker/subscriptions","organizations_url":"https://api.github.com/users/looker/orgs","repos_url":"https://api.github.com/users/looker/repos","events_url":"https://api.github.com/users/looker/events{/privacy}","received_events_url":"https://api.github.com/users/looker/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/looker/actions","description":null,"fork":false,"url":"https://api.github.com/repos/looker/actions","forks_url":"https://api.github.com/repos/looker/actions/forks","keys_url":"https://api.github.com/repos/looker/actions/keys{/key_id}","collaborators_url":"https://api.github.com/repos/looker/actions/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/looker/actions/teams","hooks_url":"https://api.github.com/repos/looker/actions/hooks","issue_events_url":"https://api.github.com/repos/looker/actions/issues/events{/number}","events_url":"https://api.github.com/repos/looker/actions/events","assignees_url":"https://api.github.com/repos/looker/actions/assignees{/user}","branches_url":"https://api.github.com/repos/looker/actions/branches{/branch}","tags_url":"https://api.github.com/repos/looker/actions/tags","blobs_url":"https://api.github.com/repos/looker/actions/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/looker/actions/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/looker/actions/git/refs{/sha}","trees_url":"https://api.github.com/repos/looker/actions/git/trees{/sha}","statuses_url":"https://api.github.com/repos/looker/actions/statuses/{sha}","languages_url":"https://api.github.com/repos/looker/actions/languages","stargazers_url":"https://api.github.com/repos/looker/actions/stargazers","contributors_url":"https://api.github.com/repos/looker/actions/contributors","subscribers_url":"https://api.github.com/repos/looker/actions/subscribers","subscription_url":"https://api.github.com/repos/looker/actions/subscription","commits_url":"https://api.github.com/repos/looker/actions/commits{/sha}","git_commits_url":"https://api.github.com/repos/looker/actions/git/commits{/sha}","comments_url":"https://api.github.com/repos/looker/actions/comments{/number}","issue_comment_url":"https://api.github.com/repos/looker/actions/issues/comments{/number}","contents_url":"https://api.github.com/repos/looker/actions/contents/{+path}","compare_url":"https://api.github.com/repos/looker/actions/compare/{base}...{head}","merges_url":"https://api.github.com/repos/looker/actions/merges","archive_url":"https://api.github.com/repos/looker/actions/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/looker/actions/downloads","issues_url":"https://api.github.com/repos/looker/actions/issues{/number}","pulls_url":"https://api.github.com/repos/looker/actions/pulls{/number}","milestones_url":"https://api.github.com/repos/looker/actions/milestones{/number}","notifications_url":"https://api.github.com/repos/looker/actions/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/looker/actions/labels{/name}","releases_url":"https://api.github.com/repos/looker/actions/releases{/id}","deployments_url":"https://api.github.com/repos/looker/actions/deployments","created_at":"2017-04-06T23:15:13Z","updated_at":"2019-02-20T20:47:39Z","pushed_at":"2019-02-21T22:49:01Z","git_url":"git://github.com/looker/actions.git","ssh_url":"git@github.com:looker/actions.git","clone_url":"https://github.com/looker/actions.git","svn_url":"https://github.com/looker/actions","homepage":null,"size":17397,"stargazers_count":7,"watchers_count":7,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":37,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14,"open_issues":37,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/looker/actions/pulls/219"},"html":{"href":"https://github.com/looker/actions/pull/219"},"issue":{"href":"https://api.github.com/repos/looker/actions/issues/219"},"comments":{"href":"https://api.github.com/repos/looker/actions/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/looker/actions/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/looker/actions/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/looker/actions/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/looker/actions/statuses/98155e6dac2ba53c644d494cded8a6eaaae2bfb8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"JimRottinger"}}