google-sheets-shortcut
A small glitch app for appending to a Google Sheet from iOS Shortcuts
Getting Started
- You will need to create an app and enable the Google Sheets API.
- Then get the client ID and secret, and set them in the
.envfile. To do this, go toCreate Credentials>OAuth client ID. You will then need to setup the OAuth content screen but all you have to do is set a product name, all other fields are optional. Click save and set the Application type to ‘Web application’. Then you need to provide the ‘Authorized redirect URIs’. This is your Glitch project URL, with '/login/google/return' appended to the end. Your Glitch project URL has the formathttps://project-name.glitch.me. Once done, click Create. Then copy and paste the generated client ID and secret into the.envfile in your Glitch project.
Template .env Configuration
CLIENT_ID=
CLIENT_SECRET=
REFRESH_TOKEN=
SHEET_KEY=
SECRET_KEY=
- You get the
SHEET_KEYfrom your spreadsheet's URL. - The
SECRET_KEYis something you should choose. This will be used to authenticate the endpoint from your iOS Shortcut. A good choice would be to use runopenssl rand -base64 24in your terminal. - Sign in via the link shown on the homepage of your created Glitch app.
- Go to the Glitch console. You should see that the OAuth tokens have been displayed. Save your
refresh_tokento the.envfile. - You can now call the endpoint with a POST to
https://YOUR-PROJECT-NAME.glitch.com/spreadsheetand the following JSON body structure:
{
"secret_key": "some secret" // This must match the secret key in your .env file
"spreadsheet_key": "" // The spreadsheet to edit. Optional (defaults to the SHEET_KEY set in .env)
"data": ["foo", "bar", "baz"] // A list of values to append to the spreadsheet as a single row
"spreadsheet_range": "" // Optional. Where to append the new row (useful if you want to append on the non-default tab of a sheet)
}Attribution
This was remixed from https://glitch.com/~google-sheets