Pandas read_csv from Google Cloud Storage?

I am trying to read in a .csv from Google Cloud Storage in a Streamlit Cloud app. When I am testing locally, the following code works with no issues:

credentials = service_account.Credentials.from_service_account_info(
    st.secrets['gcp_service_account'], scopes=["https://www.googleapis.com/auth/cloud-platform"])

data = pd.read_csv(path,
                    storage_options={'token' : credentials},
                    low_memory=False,
                    index_col=0)

However when I deploy to Streamlit Cloud, I am getting the following error:

KeyError: 'st.secrets has no key "gcp_service_account". Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? More info: https://docs.streamlit.io/streamlit-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management'

I copied and pasted the credentials exactly the same as the secrets.toml I have locally into the secrets manager for Streamlit Cloud.

When I read the docs concerning Secrets Management, I noticed the syntax for calling an entire section of the toml file was as follows:

my_db.connect(**st.secrets.db_credentials)

Is this just a simple syntax error on my part? Are the double asterisks (**) doing something here that I’m not understanding? Thank you!

Just an update here-- simple solution. When first creating the Streamlit app, my .toml section header [gcp_service_account] did not save for some reason. Going into the app settings, and modifying the secrets to include the section header made things work no problem.

Hello Nate,
How did you the code in your app to include the secrets files? I can’t seem to complete the connection.

Here is mine but I get an error message to add another module and ‘no module named oauthlib’

credentials = service_account.Credentials.from_service_account_info(
st.secrets[‘gcp_service_account’]

Thanks!