What the agent does
The agent reads how the app identifies people today before it adds a sign-in, because in this app it does not. In an app shaped like streamlit/llm-examples, Chatbot.py and the five pages under pages/ each open with a sidebar st.text_input for an API key, type="password", keyed chatbot_api_key, file_qa_api_key and so on, and stop with an st.info message until one is typed; the key is the only thing standing between a visitor and a model call billed to someone. requirements.txt pins streamlit>=1.28, openai>=1.2, langchain==0.0.350 and anthropic>=0.3.0; there is no .streamlit/ directory, and .gitignore already lists secrets.toml. app_test.py has two tests on streamlit.testing.v1.AppTest: test_Chatbot loads Chatbot.py, sends a chat message with no key and asserts the st.info text, then patches openai.resources.chat.Completions.create, types a key and asserts the reply; test_Langchain_Quickstart does the same for one page. .github/workflows/app-testing.yml runs streamlit/streamlit-app-action on Chatbot.py with ruff: true and pytest-args, and .ruff.toml sets the line length to 105.
Streamlit has had native OpenID Connect sign-in since 1.42.0: st.login() redirects to the provider, st.user holds the identity afterwards, and st.logout() clears it. It needs Authlib>=1.3.2, and its configuration lives in .streamlit/secrets.toml under [auth]: redirect_uri ending in oauth2callback, a cookie_secret, and for Google the client_id, client_secret and server_metadata_url of https://accounts.google.com/.well-known/openid-configuration. The agent raises the streamlit floor in requirements.txt to a release that has st.user as a stable API, adds Authlib>=1.3.2, and commits .streamlit/secrets.toml.example with those five keys and placeholder values, since the real file is gitignored.
The sign-in goes in one place. A new auth.py module exposes require_login(), which returns when st.user.is_logged_in is true and otherwise renders a title, a st.button("Log in with Google") whose click calls st.login(), and st.stop(); and sidebar_user(), which shows st.user.name with a Log out button that calls st.logout(). Chatbot.py and each page call require_login() first and sidebar_user() inside their existing with st.sidebar: block, above the API key input, so a visitor who is not signed in never sees the key field or the chat input, and every page keeps its own key handling as it was. The pull request explains the one step only the reader can do: create an OAuth client in Google Cloud with the redirect_uri from the secrets file as an authorised redirect, which for local work is http://localhost:8501/oauth2callback.
The tests change with the pages. AppTest runs a script without a browser and cannot complete an OAuth redirect, so the agent tests the two states it can reach: with no identity, the app renders the login button and neither the chat input nor the key field, which becomes a new case per page; and with an identity, the existing round-trip tests still pass, by patching auth.require_login and auth.sidebar_user in those tests only, which keeps the model-call assertions untouched. It runs ruff check . and pytest -v, the two things the workflow runs, with a secrets.toml written from the example so st.login finds its configuration, then starts streamlit run Chatbot.py in the sandbox and opens it in the browser to screenshot the login page and the redirect to Google's consent screen, which is as far as a run without the reader's client can go, and says so.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add Google login to this Streamlit app with st.login and open a pull request. Read Chatbot.py, every file under pages/, app_test.py, requirements.txt, requirements-dev.txt, .ruff.toml, .gitignore, README.md and .github/workflows/app-testing.yml first. Raise the streamlit floor in requirements.txt to a release where st.user is stable and add Authlib>=1.3.2. Add .streamlit/secrets.toml.example with an [auth] section holding redirect_uri, cookie_secret, client_id, client_secret and server_metadata_url for Google, with placeholder values; the real secrets.toml is already gitignored. Write auth.py with require_login(), which calls st.stop() behind a Log in with Google button that calls st.login() unless st.user.is_logged_in, and sidebar_user(), which shows st.user.name and a Log out button that calls st.logout(). Call require_login() at the top of Chatbot.py and every page, and sidebar_user() inside each existing sidebar block above the API key input; change nothing else on the pages. In app_test.py add a logged-out case per page asserting the login button renders and no chat input or key field does, and keep the existing round-trip tests passing by patching the two auth functions in those tests only. Run ruff check . and pytest -v with a secrets.toml written from the example, start streamlit run Chatbot.py, open it in the browser and screenshot the login page and the redirect to Google. Add a README section on creating the Google OAuth client and the redirect URI. Paste every result in the pull request and say that the sign-in itself could not be completed without the reader's client.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that adds auth.py, .streamlit/secrets.toml.example and a README section, changes two lines in requirements.txt, adds two calls to Chatbot.py and each page under pages/, and extends app_test.py with a logged-out case per page plus the patches that keep the existing two tests green. The description shows the [auth] keys with placeholders, the ruff check and pytest -v output, the screenshots of the login page and of Google's consent screen, and says plainly that completing the sign-in needs the reader's OAuth client.
The repository's App testing workflow runs the same ruff and pytest steps on the pull request through streamlit-app-action, with the results summarised on the check. The run's record keeps every command with its output, including the streamlit run session and the browser steps.
Before merging, a reviewer creates the OAuth client in Google Cloud, adds their deployed redirect_uri to it, fills secrets.toml from the example, and signs in once. They also decide whether every page should require sign-in or only the ones that spend money, and whether st.user.email should be checked against an allow-list, which is a one-line addition to require_login().
Run it on every Streamlit app shared outside the team
A team with several Streamlit apps starts one run per repository from the terminal with POST /o/{org}/sessions, this prompt and the repository in resources. Each run reads that app's own pages and tests, so an app with a single script gets one require_login() call and an app that already has a login replaces nothing, and each run opens its own pull request.
Give the API key a webhook_url and run.completed arrives with data.session_url for each run, so the pull request links and screenshots collect in one place.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
Adding sign-in to a multipage app is mostly bookkeeping: the same two calls on every page, a secrets layout that must not be committed, a floor bump that pip has to agree with, and a test suite that must still pass when the pages stop short of their inputs. In a Rush sandbox the agent makes all of those changes together, runs the app's own AppTest suite and ruff, starts the server and walks the login page in a real browser, and keeps the output and screenshots in the run's record beside the pull request.
The one step that needs a person, creating the OAuth client, is written down with the exact redirect URI the secrets file uses, so the reviewer's first sign-in is the only thing left to do. The same request works unchanged on the next Streamlit app that is about to be shared.
Frequently asked questions
Why Google, and can I use another provider?
st.login speaks OpenID Connect, and Google is the provider most teams already have. Any OIDC provider works by changing server_metadata_url, client_id and client_secret in the [auth] section; the pages do not change.
Can the tests sign in?
No. AppTest runs the script without a browser and cannot follow the OAuth redirect, so the new tests assert the logged-out page and the existing round-trip tests patch the two auth functions. The signed-in path is proven by the reviewer's first login.
Do the API key inputs go away?
No. Sign-in only decides who gets to see them. Each page keeps its own key field and its own st.info message, so the existing behaviour and tests around the model call stay as they are. Moving the keys into secrets.toml is a separate change.
Which Streamlit version does this need?
st.login and st.logout arrived in 1.42.0, and st.user became a stable API in 1.45.0. The pull request raises the floor in requirements.txt to the release it tested against and names it.
More Streamlit jobs
The same job on other stacks
- Add Google Login to an AdonisJS App (AdonisJS)
- Add Google Login to an Express and Mongoose API (Mongoose)
- Add Google Login to a Next.js App with NextAuth.js (NextAuth.js)