Skip to content

Extract data from Goole Drive files and spreadsheets

License

Notifications You must be signed in to change notification settings

keboola/google-drive-extractor-config-rows

Repository files navigation

google-drive-extractor based on configRows configurations

License

Extract data from Goole Drive files and spreadsheets.

Example configuration

{
   "parameters": {
      "fileId": "FILE_ID",
      "fileTitle": "FILE_TITLE",
      "sheetId": "THE_GID_OF_THE_SHEET",
      "sheetTitle": "SHEET_TITLE",
      "outputTable": "FILE_TITLE"
   }
}

OAuth Registration

Note that this extractor is using Keboola OAuth Bundle to store OAuth credentials.

  1. Create application in Google Developer console.
  • Enable APIs: Google Drive API, Google Sheets API
  • Go to Credentials section and create new credentials of type OAuth Client ID. Use https://SYRUP_INSTANCE.keboola.com/oauth-v2/authorize/keboola.ex-google-drive/callback as redirec URI.
  1. Register application in Keboola Oauth http://docs.oauthv2.apiary.io/#reference/manage/addlist-supported-api/add-new-component
{ 
    "component_id": "keboola.ex-google-drive",
    "friendly_name": "Google Drive Extractor",
    "app_key": "XXX.apps.googleusercontent.com",
    "app_secret": "",
    "auth_url": "https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_uri=%%redirect_uri%%&client_id=%%client_id%%&access_type=offline&prompt=consent&scope=https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets.readonly",
    "token_url": "https://www.googleapis.com/oauth2/v4/token",
    "oauth_version": "2.0"
}

Development

App is developed on localhost using TDD.

  1. Clone from repository: git clone git@github.com:keboola/google-drive-extractor.git
  2. Change directory: cd google-drive-extractor
  3. Build docker image: docker-compose build
  4. Install dependencies: docker-compose run --rm dev composer install --no-scripts
  5. You will need working OAuth credentials.
    • Go to Googles OAuth 2.0 Playground.
    • In the configuration (the cog wheel on the top right side) check Use your own OAuth credentials and paste your OAuth Client ID and Secret.
    • Go through the authorization flow and generate Access and Refresh tokens. Copy and paste them into the tests.sh file.
  6. Run the tests: docker-compose run --rm dev composer tests