Connect Streamlit to a public Google Sheet
Introduction
This guide explains how to securely access a public Google Sheet from Streamlit Cloud. It uses the gsheetsdb library and Streamlit's secrets management.
This method requires you to enable link sharing for your Google Sheet. While the sharing link will not appear in your code (and actually acts as sort of a password!), someone with the link can get all the data in the Sheet. If you don't want this, follow the (more complicated) guide Connect Streamlit to a private Google Sheet.
Create a Google Sheet and turn on link sharing
If you already have a Sheet that you want to access, feel free to skip to the next
step.
Add the Sheets URL to your local app secrets
Your local Streamlit app will read secrets from a file .streamlit/secrets.toml in your app's root directory. Create this file if it doesn't exist yet and add the share link of your Google Sheet to it as shown below:
