# Using python-dotenv with Dash-based app hosted on Heroku

**URL:** https://community.plotly.com/t/using-python-dotenv-with-dash-based-app-hosted-on-heroku/31576
**Category:** Dash Python
**Created:** [November 19, 2019, 7:38pm UTC](https://community.plotly.com/t/using-python-dotenv-with-dash-based-app-hosted-on-heroku/31576 "2019-11-19T19:38:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![arpitr07](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@arpitr07](https://community.plotly.com/u/arpitr07)
#### Post date: [November 19, 2019, 7:38pm UTC](https://community.plotly.com/t/using-python-dotenv-with-dash-based-app-hosted-on-heroku/31576/1 "2019-11-19T19:38:12Z")

</div>

I’ve got a Dash-based application. This app makes an API call to source data, which in turn is plotted on a dashboard. In order to make this API call, I have an API access token.

For obvious reasons, I’d want to keep the API-Key secret.

This [resource](https://github.com/theskumar/python-dotenv) tells me how to use python-dotenv to do exactly that with a Flask or Django app.

It says nothing about a Dash-app though. I know, Dash uses Flask in the background but the steps suggested in the above resource do not help me.

Any ideas on this would be appreciated.

---

<div class="post-metadata">

### Author: ![flyingcujo](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@flyingcujo](https://community.plotly.com/u/flyingcujo)
#### Post date: [November 19, 2019, 7:51pm UTC](https://community.plotly.com/t/using-python-dotenv-with-dash-based-app-hosted-on-heroku/31576/2 "2019-11-19T19:51:23Z")

</div>

In Heroku, you can setup Config Vars (click on Settings tab within your Heroku project). These config vars are then set as environment variables when your app is deployed.

Within your python code, you can access them via the following:

```python
os.getenv('YOUR_CONFIG_VAR')

```

If not already done, you will also need:

```python
import os

```

---

<div class="post-metadata">

### Author: ![arpitr07](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@arpitr07](https://community.plotly.com/u/arpitr07)
#### Post date: [November 19, 2019, 9:15pm UTC](https://community.plotly.com/t/using-python-dotenv-with-dash-based-app-hosted-on-heroku/31576/3 "2019-11-19T21:15:55Z")

</div>

Thank you. That worked for me!
