How can I access the Repo secrets in the code? I canโt seem to find any related documentation. Appreciate any help!
NVM, I solved it. It seems that the secrets are available as environment variables: Spaces Overview.
1 Like
@IssakaAI Can you show how you referenced the secret here?
Thanks!
Hi @iamrobotbear. In the Space settings, you can set Repository secrets. In your code, you can access these secrets just like how you would access environment variables.
For example, if there is a Repository secret called API_TOKEN
, you can access it using os.environ['API_TOKEN']
.
4 Likes