Pydrive does not work after deploying my app on Streamlit Cloud

Hello everyone,
I have created an app which takes some info from the user and uploads it to Google Sheets (simple database). I have also added an upload file widget which is supposed to upload a file from the user to drive using the pydrive library. This worked perfectly before deploying the app, but now I am having problems with it. The error I am getting is:

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/", line 552, in _run_script
    exec(code, module.__dict__)
File "/app/testing/", line 409, in <module>
File "/app/testing/", line 262, in main
File "/home/appuser/venv/lib/python3.9/site-packages/pydrive/", line 285, in Upload
File "/home/appuser/venv/lib/python3.9/site-packages/pydrive/", line 57, in _decorated
File "/home/appuser/venv/lib/python3.9/site-packages/pydrive/", line 115, in _decorated
    code = decoratee(self, *args, **kwargs)
File "/home/appuser/venv/lib/python3.9/site-packages/pydrive/", line 224, in LocalWebserverAuth
    raise AuthenticationError()```

Code snippet of my code which produces the error:

with NamedTemporaryFile() as f:
                gauth = GoogleAuth()
                drive = GoogleDrive(gauth)
                client_json_path = 'path'    
                GoogleAuth.DEFAULT_SETTINGS['client_config_file'] = client_json_path
                drive_key = st.secrets["drive_key"]
                gfile = drive.CreateFile({"parents": [{"id": drive_key}], "title":})

Thanks in advance for any help

pydrive.auth.AuthenticationError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).

I forgot to add the name of the error.

Hi, there seems to be an issue with authentication, and from your code there is a reference to st.secrets, have you defined β€œdrive_key” in the Secrets management on the Streamlit Community Cloud?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.