<aside> ⚠️ DEPRECATED!!! This guide migrated to our docs. Please view the current version at: https://docs.streamlit.io/en/stable/tutorial/tableau.html
</aside>
This guide explains how to securely access data on Tableau from Streamlit sharing or Streamlit for Teams. It uses the tableauserverclient library and Streamlit's secrets management (requires streamlit v0.80.0 or higher).
<aside> 🏃 If you already have a Tableau site that you want to use, feel free to skip this step.
</aside>
For simplicity, we are using the cloud version of Tableau here but this guide works equally well for self-hosted deployments. First, sign up for Tableau Online or log in. Create a workbook or simply run one of the example workbooks under "Dashboard Starters".
<aside> ☝ The Tableau API allows authentication via username and password but for a production app, you should use personal access tokens. Note that they expire if not used after 15 consecutive days.
</aside>
Go to your Tableau Online homepage, create an access token (click screenshots to enlarge) and note down the token name and secret.
<aside> 🤫 Store the token in a safe location and don't share it with anyone.
</aside>
Your local Streamlit app will read secrets from a file .streamlit/secrets.toml
in your app's root dir. Create this file if it doesn't exist yet and add your token, the site name you created during setup, and the URL of your Tableau server like below:
# .streamlit/secrets.toml
[tableau]
token_name = "xxx"
token_secret = "xxx"
server_url = "<https://abc01.online.tableau.com/>"
site_id = "streamlitexample" # in your site's URL behind the server_url
<aside>
☝ Add this file to .gitignore
and don't commit it to your Github repo!
</aside>
As the secrets.toml
file above is not commited to Github, you need to pass its content to your deployed app (on Streamlit sharing or Streamlit for Teams) separately. Go to the app dashboard and in the app's dropdown menu, click on Edit Secrets. Copy the content of secrets.toml
into the text area. More infos in Secrets Management.