I’ve got the exact same problem as described in this topic, but it is closed, so I can’t answer there (maybe re-open?)
The link to the github repository of the package is: GitHub - dnplus/streamlit-oauth: Simple OAuth Component for Streamlit App
minimum reproducable code:
config.toml
[logger]
level = 'debug'
[server]
enableStaticServing = true
[runner]
fastReruns = false
main.py
import streamlit as st
from streamlit_oauth import OAuth2Component
# Set environment variables
kadiApiBaseURL = 'https://kadi4mat.iam.kit.edu'
AUTHORIZE_URL = kadiApiBaseURL + '/oauth/authorize'
TOKEN_URL = kadiApiBaseURL + '/oauth/token'
REFRESH_TOKEN_URL = kadiApiBaseURL + '/oauth/token'
REVOKE_TOKEN_URL = kadiApiBaseURL + '/oauth/revoke'
CLIENT_ID = st.secrets['oauthClientID']
CLIENT_SECRET = st.secrets['oauthClientSecret']
REDIRECT_URI = 'https://[[**YOUR APP**]].streamlit.app/component/streamlit_oauth.authorize_button/index.html'
SCOPE = ''
# Create OAuth2Component instance
oauth2 = OAuth2Component(CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL, REFRESH_TOKEN_URL, REVOKE_TOKEN_URL)
result = oauth2.authorize_button("Authorize", REDIRECT_URI, SCOPE, height=800, width=400, use_container_width=True, extras_params={'response_type': 'code'})
if result and 'token' in result:
# If authorization successful, save token in session state
st.session_state.token = result.get('token')
st.rerun()
Since I assume you don’t have a Kadi4Mat account, this is the log after clicking on “Authorize” - streamlit loads the redirect and gives “read error” in the popup afterwards. I think this can be reproduced with other URLs as well
streamlit console log
2024-04-26 13:09:20.502 Registered component 'streamlit_oauth.authorize_button': /home/adminuser/venv/lib/python3.12/site-packages/streamlit_oauth/frontend/dist
2024-04-26 13:09:20.508 Creating new DataCache (key=#####data cache key####, persist=None, max_entries=None, ttl=300)
2024-04-26 13:09:20.508 Cache key: #####some key####
2024-04-26 13:09:20.509 Memory cache MISS: #####some key####
2024-04-26 13:09:20.509 Memory cache MISS: #####some key####
2024-04-26 13:09:20.509 Memory cache MISS: #####some key####
2024-04-26 13:09:20.916 Removing orphaned files...
2024-04-26 13:09:21.017 Script run finished successfully; removing expired entries from MessageCache (max_age=2)
2024-04-26 13:09:38.887 ComponentRequestHandler: GET /home/adminuser/venv/lib/python3.12/site-packages/streamlit_oauth/frontend/dist read error
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/web/server/component_request_handler.py", line 54, in get
with open(abspath, "rb") as file:
^^^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: '/home/adminuser/venv/lib/python3.12/site-packages/streamlit_oauth/frontend/dist'