Hi,
I’m encountering an issue while trying to set up my Streamlit app in Streamlit Cloud. I’m using a Hugging Face token for authentication with the Hugging Face API, and I’m trying to set this token as an environment variable using Streamlit’s secrets feature.
Here’s a summary of the problem:
my code for hugging face token looks like this:
hf_token = os.getenv("HUGGINGFACE_TOKEN")
os.environ["HUGGINGFACEHUB_API_TOKEN"] = hf_token
However, despite verifying that the secret name matches and ensuring that the secret value is correctly set in Streamlit Cloud, I’m still encountering issues with authentication.
Here’s the relevant portion of my code:
and in advanced settings of deployed streamlit app, have added the following:
I’ve also double-checked the secret name and value, as well as ensured that the code works correctly locally.
Any suggestions or insights on what might be causing this issue or how I can troubleshoot it further would be greatly appreciated.
Thank you!
NOTE: I have added a proper hugging face token