Skip to content

st.login() when using Google - state parsing appears to be incorrect #10356

@daileykluck

Description

@daileykluck

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When attempting to configure st.login() with our application, we are getting an error that indicates that the state might not be properly set according to the code that attempts to parse it.

We have confirmed that the received state is the same as the outgoing state, but upon redirect it looks like it doesn't parse as expected.

Reproducible Code Example

# streamlit.py

import streamlit as st

if st.button("Log in with Google"):
            st.login(provider='google_dev')


# secrets.toml
[auth]
redirect_uri = "http://localhost:8501/oauth2callback"
cookie_secret = "somesecret"

[auth.google_dev]
client_id = "something-something.apps.googleusercontent.com"
client_secret = "some-secret"
server_metadata_url = "https://accounts.google.com/.well-known/openid-configuration"

Steps To Reproduce

  1. Click on the button
  2. Select your profile
  3. Check server logs

Expected Behavior

I would have expected what looked to be an incredibly easy way to replace our current homegrown implementation of OAuth in Streamlit! Really pumped for this, just hitting a minor snag that I think looks like a bug.

Current Behavior

Traceback (most recent call last):
...
venv/lib/python3.11/site-packages/streamlit/web/server/oauth_authlib_routes.py", line 128, in get
    provider = self._get_provider_by_state()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../.venv/lib/python3.11/site-packages/streamlit/web/server/oauth_authlib_routes.py", line 157, in _get_provider_by_state
    _, _, recorded_provider, code = key.split("_")
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 4)

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.42.0
  • Authlib version: 1.4.1
  • Python version: 3.11
  • Operating System: MacOS 15.2 (24C101)
  • Browser: Version 132.0.6834.160 (Official Build) (arm64)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:authenticationRelated to user authenticationpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions