Streamlit with Okta sign in - after refresh how do iI remove code/state from the url?

I noticed upon testing my streamlit page that I see a 400 client error for the token url.

400 Client Error: Bad Request for url: https://xxx.okta.com/oauth2/v1/token

I believe because after i refreshed the page I still see the state and code in the url of the streamlit page. Is there a way that upon refresh delete state/code?

So my url looks like this after resfresh:

https://streamlitsite.net/?code=dkdsfyysdf823dflIsis&state=dkfd8ekdsldk

and I just want it to look like this again:
https://streamlitsite.net

You can use st.query_params.clear() before refreshing the page

Thanks for responding! what if statement would this be under?

I’ve just tried this and nothing happened


if not st.session_state["messages"]:
    st.query_params.clear()

I don’t know if you send a form via form_submit_button(), use st.rerun() or refresh the page in other ways, but you need to put that before refreshing the app.

Example:

code = st.query_params.get("code")
# use the code (and optionally store info in session_state)
st.query_params.clear()
st.rerun()

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.