I am using pywebview to display the Streamlit app that includes an OAuth2 button. The button relies on window.open to open an external popup. While this works perfectly in a standard browser (Chrome/Edge), it fails when the app is embedded in pywebview.
pywebview
?I chose pywebview to bundle my Streamlit app into a lightweight desktop application with a native window experience.
When the button is clicked, window.open
fails inside pywebview
. The following error appears in the developer console:
Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'r.focus')
I tried replacing window.open
with window.location.href = jr;
as a workaround, but this results in another issue:
Failed to load resource: the server responded with a status of 403 (Forbidden)
I am not proficient in JavaScript, so I wasn’t able to debug this further.
Run the following Python code to open the Streamlit app in pywebview
:
import webview
if __name__ == "__main__":
window = webview.create_window(
"OAuth2 Window",
url="http://localhost:8501",
)
webview.start()
pywebview
This seems to be related to pywebview
’s known limitation where window.open
is not supported:
It would be great if the streamlit_oauth
library could detect environments like pywebview
where window.open
is unsupported and provide an alternative mechanism, such as navigating directly to the OAuth URL with window.location.href
.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too