Keboola component that writes data from Keboola Storage tables into Google Drive. Supports:
- Creating new files or updating existing ones
- CSV files and Google Sheets formats
- Configurable file conversion and permissions
{
"authorization": {
"oauth_api": {
"id": "keboola.wr-google-drive-abc-def",
"version": 3
}
},
"parameters": {
"tables": [
{
"id": 123,
"action": "create",
"enabled": true,
"convert": false,
"tableId": "in.c-test.table",
"title": "table"
}
]
},
"storage": {
"input": {
"tables": [
{
"source": "in.c-test.table",
"destination": "in.c-test.table.csv",
"where_column": "",
"where_values": [],
"where_operator": "eq",
"columns": []
}
]
}
}
}Note that this writer is using Keboola OAuth Bundle to store OAuth credentials.
- Create application in Google Developer console.
- Enable APIs:
Google Drive API,Google Sheets API - Go to
Credentialssection and create new credentials of typeOAuth Client ID. Usehttps://SYRUP_INSTANCE.keboola.com/oauth-v2/authorize/keboola.ex-google-drive/callbackas redirec URI.
- 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"
}App is developed on localhost using TDD.
- Clone from repository:
git clone git@github.com:keboola/google-drive-writer.git - Change directory:
cd google-drive-writer - Install dependencies:
docker compose run --rm dev composer install - 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 credentialsand paste your OAuth Client ID and Secret. - Go through the authorization flow and generate
AccessandRefreshtokens. Copy and paste them into the.envfile.
- Run the tests:
docker compose run --rm dev composer tests
- Create a
datadirectory withconfig.json(see Example configuration above) - Add your input CSV files to
data/in/tables/ - Run the component:
docker compose run --rm dev php src/run.php --data=/data
MIT licensed, see LICENSE file.