St.secrets has no attribute "XXX". Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud?

Hi guys,

I’m new to this community. As I’m deploying my app on Streamlit Cloud, even though I have edit my secret as below:


And in the source code I call out the key “type” in secrets like this:
api_key = {
“type”: st.secrets[“type”],
“project_id”: st.secrets[“project_id”],
“private_key_id”:st.secrets[“private_key_id”],
“private_key”:st.secrets[“private_key”],
“client_email”:st.secrets[“client_email”],
“client_id”:st.secrets[“client_id”],
“auth_uri”:st.secrets[“auth_uri”],
“token_uri”:st.secrets[“token_uri”],
“auth_provider_x509_cert_url”:st.secrets[“auth_provider_x509_cert_url”],
“client_x509_cert_url”:st.secrets[“client_x509_cert_url”],
“universe_domain”:st.secrets[“universe_domain”]
}
But the app say there’s an error “st.secrets has no attribute “type”. Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud?”

How do I fix this problem.

Thank you

Do the other secrets work? If so, I would replace “type” with another word, since that is a keyword in Python.

Yes, I have tried with universe_domain and still got the same error

st.secrets['gcp_service_account']['type']

…should work?

Ah, there is such error because perhaps the syntax that I used to call them as:
“type”: st.secrets[“type”],
“project_id”: st.secrets[“project_id”],
“private_key_id”:st.secrets[“private_key_id”],
“private_key”:st.secrets[“private_key”],
“client_email”:st.secrets[“client_email”],
“client_id”:st.secrets[“client_id”],
“auth_uri”:st.secrets[“auth_uri”],
“token_uri”:st.secrets[“token_uri”],
“auth_provider_x509_cert_url”:st.secrets[“auth_provider_x509_cert_url”],
“client_x509_cert_url”:st.secrets[“client_x509_cert_url”],
“universe_domain”:st.secrets[“universe_domain”]

If I give each of them a variable, it should work, I’ll will respond if it worked.

Thank you

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