Google OAuth authentication issue in Streamlit Cloud: Connection refused after redirection

I am facing an issue with Google authentication in my Streamlit application when deployed to Streamlit Cloud. The application works fine on local environment but fails on production environment.

Current configuration:

  • I am using Google OAuth for authentication.
  • The redirect_uri is set correctly
  • The credentials are stored in secrets.toml.

The problem:

When the application is running on Streamlit Cloud and the user clicks the button to sign in with Google, the redirection to Google for authentication results in a connection refused.

What I have already checked:

  1. The credentials in the secrets.toml of Streamlit Cloud are correct.
  2. The redirect_uri in the code matches what is configured in Google Cloud Console.
  3. The authorized JavaScript sources include the correct url.

Question:

Has anyone faced a similar issue or can suggest other debugging steps to resolve this authentication issue in Streamlit Cloud?

I would appreciate any help or guidance on how I can resolve this Google OAuth authentication issue in the Streamlit Cloud environment, locally it is working perfectly.