- Live Demo: check https://netlify-google-spreadsheet-demo.netlify.com/
- Spreadsheet (read only): https://docs.google.com/spreadsheets/d/10FIUu_reo5FctMpuiOYHJstj3lTit4pvp-VS7mZhgVw/edit?usp=sharing
- Blogpost: https://www.swyx.io/writing/netlify-google-sheets
How to get the env vars: tutorial to be fleshed out
-
make a google sheet. its id from url will be
GOOGLE_SPREADSHEET_ID_FROM_URL
-
head to google console and make sure the Sheets API is enabled https://console.developers.google.com/apis/library/sheets.googleapis.com?project=sixth-storm-268221. you may need to set up a "project" for this if this is your first time.
- get the service account key, NOT the API key. this might help: https://github.com/theoephraim/node-google-spreadsheet/blob/756d57fea3e1cf1d5ba6a38b12210102da0bf621/docs/getting-started/authentication.md. this will give you
GOOGLE_SERVICE_ACCOUNT_EMAIL
andGOOGLE_PRIVATE_KEY
(see form below)
- Make sure your sheet has granted permission https://stackoverflow.com/questions/38949318/google-sheets-api-returns-the-caller-does-not-have-permission-when-using-serve to
GOOGLE_SERVICE_ACCOUNT_EMAIL
make sure to set env vars inside functions/google-spreadsheet-fn/.env
:
TRY_TO=CUSTOMIZE_THIS
GOOGLE_SPREADSHEET_ID_FROM_URL= # e.g. 10abcu_reo5FctMpuiOYHJstj3lTit4pvp-VS7mZhgVw
GOOGLE_SERVICE_ACCOUNT_EMAIL= # e.g. googlenetlify-spreadsheet-test@foo-bar-123456.iam.gserviceaccount.com
GOOGLE_PRIVATE_KEY= # e.g. -----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG etc etc super long key
and then with the Netlify CLI you can run ntl dev
(Netlify Dev) and it opens up locally for you to develop.
make sure to set the env vars in the netlify UI