Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update data apps default secrets #689

Merged
merged 4 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions components/data-apps/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,21 @@ To provide your app with environment variables or sensitive information like cre
These secrets will be injected into the `secrets.toml` file upon deployment of the app.
[Read more about the Streamlit secrets](https://docs.streamlit.io/streamlit-community-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management).

### Default Secrets
By default, the Keboola Streamlit Docker image includes two secrets that do not require explicit specification:
## Access Storage from Data App
By default, there are two environment variables available that make it easy to access Keboola storage from your application:

- `kbc_url`: This represents the URL of the current Keboola project.
- `kbc_token`: This represents the storage token with full read-write access to Keboola Storage.
- `KBC_URL`: This represents the URL of the current Keboola project.
- `KBC_TOKEN`: This represents the storage token with full read-write access to Keboola Storage.

These secrets can be accessed within your Streamlit data app code. Here is an example of how to initialize the Keboola storage token:
These environment variables can be accessed within your Streamlit data app code. Here is an example of how to initialize the Keboola storage token:
```
token = st.secrets["kbc_storage_token"]
url = st.secrets["kbc_url"]
client = Client(url, token)
# Constants
kbc_token = os.environ.get('KBC_TOKEN')
kbc_url = os.environ.get('KBC_URL')
# Initialize Client
client = Client(kbc_url, kbc_token)
```

![Secrets](/components/data-apps/data_apps-secrets.png)
These variables represent the project where the application is deployed. To map data from a different project, you need to configure the appropriate secrets.

## Loading Data from Storage
To load data from the storage of a Keboola project into the app, use the [input mapping](https://help.keboola.com/transformations/mappings/#input-mapping) section.
Expand Down