<aside> ⚠️ DEPRECATED!!! This guide migrated to our docs. Please view the current version at: https://docs.streamlit.io/en/stable/tutorial/tableau.html

</aside>

Introduction

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).

Step 1: Create a Tableau site

<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".

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ae726505-0f63-44d0-a705-6de1d12c0f40/Screenshot_2021-04-18_at_01.05.44.png

Step 2: Create personal access tokens

<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.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/74e2bae7-86ea-4931-877d-6db9593619b4/Screenshot_2021-04-21_at_21.55.41.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9afad5f3-5882-433d-b9e2-dd2c5dc8e778/Screenshot_2021-04-21_at_21.56.53.png

<aside> 🤫 Store the token in a safe location and don't share it with anyone.

</aside>

Step 3: Add token to your local app secrets

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>

Step 4: Copy your app secrets to the cloud

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.