Regrettably, there isn't currently a way to enable end users of the app to set secrets. The optimal alternative at this point in time is to generate a st.text_input
field to allow users to input their own API key.
Here's a code snippet that demonstrates how to use the st.text_input
field to allow users to enter their API key:
import streamlit as st # Create a text input field for the user to enter their API key api_key = st.text_input("Enter your API key") # Use the API key to make a request to an API response = requests.get("https://example.com/api/v1/data", headers={"Authorization": f"Bearer {api_key}"}) # Display the response from the API st.write(response.json())
This approach provides a simple and straightforward way for users to provide their own API key, while maintaining the security of your Streamlit app.