Private Google Sheets - Invalid URL Error only when Deploying

Hi, I get the following error only when I deploy (works on local):

gsheetsdb.exceptions.InterfaceError: Invalid URL, must be a URL!

This is from the following lines:

qry = f'SELECT * FROM "{sheet_url}"'
rows = conn.execute(query, headers=1)

The code works on my local machine, however it does not work whenever I deploy it - therefore I belive this is a streamlit issue, not a link/authentication issue. I’ve also confirmed (via a on the app) that the query I use is:


Folder structure is simple:

my_streamlit_app_folder >
  .streamlit > secrets.toml

Streamlit version is 1.8.1. I’ve followed the instructions step-by-step here: Connect Streamlit to a private Google Sheet - Streamlit Docs

Any ideas/suggestions for what might be going on? Been struggling with this for a few days, tried rebooting/deleting the app as well however no success so would really appreciate any thoughts - thanks!

Code is below for reference:

import streamlit as st
from google.oauth2 import service_account
from gsheetsdb import connect

# Create a connection object.
credentials = service_account.Credentials.from_service_account_info(
conn = connect(credentials=credentials)

def run_query(query):
    rows = conn.execute(query, headers=1)
    rows = rows.fetchall()
    return rows

sheet_url = st.secrets["private_gsheets_url"]
qry = f'SELECT * FROM "{sheet_url}"'
rows = run_query(qry)

for row in rows:
    st.write(f"{} has a :{}:")

And secrets.toml below - I’ve copy-pasted over my file from local to App settings > Secrets:

# .streamlit/secrets.toml

private_gsheets_url = ""

type = "service_account"
<<copied from json as per link above>>

Fixed! Solution for reference was to specify an older moz_sql_parser version in requirements.txt - I downgraded to