8000 add jwt instructions · LehmD/server-client-python@7c2a745 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c2a745

Browse files
committed
add jwt instructions
1 parent f5c66c3 commit 7c2a745

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

samples/getting_started/2_hello_site.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
####
22
# Getting started Part Two of Three
3-
# This script demonstrates how to use the Tableau Server Client to
4-
# view the content on an existing site on Tableau Server/Online
5-
# It assumes that you have already got a site and can visit it in a browser
3+
# This script demonstrates how to use the Tableau Server Client to sign in and view content.
4+
# It assumes that you have already got a Tableau site and can visit it in a browser
65
#
6+
# To make it easy to run, it doesn't take any arguments - you need to edit the code with your info
77
####
88

99
import getpass
@@ -25,17 +25,26 @@ def main():
2525
# e.g https://my-server/#/site/this-is-your-site-url-name/not-this-part
2626
site_url_name = "" # leave empty if there is no site name in the url (you are on the default site)
2727

28-
# 4 - replace with your username.
29-
# REMEMBER: if you are using Tableau Online, your username is the entire email address
28+
# 4 - login
29+
# a) replace with your Personal Access Token values from the page 'My Account' on your Tableau site
30+
token_name = "your-token-name"
31+
token_value = "your-token-value-long-random-string"
32+
tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site_url_name)
33+
34+
# OR b) to sign in with a username and password, uncomment this section and remove the three lines above
35+
# REMEMBER: if you are using Tableau Online, you cannot log in with username+password.
36+
"""
3037
username = "your-username-here"
3138
password = getpass.getpass("Your password:") # so you don't save it in this file
3239
tableau_auth = TSC.TableauAuth(username, password, site_id=site_url_name)
33-
34-
# OR instead of username+password, uncomment this section to use a Personal Access Token
35-
# by commenting out the three lines above, and uncommenting these three lines
36-
# t 8000 oken_name = "your-token-name"
37-
# token_value = "your-token-value-long-random-string"
38-
# tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site_url_name)
40+
"""
41+
42+
# OR c) to sign in with a JWT, uncomment this section and remove the three lines for PAT above
43+
# You must have configured a Connected App and generated a JWT before you use this method.
44+
"""
45+
jwt = "long-generated-string-that-encodes-information"
46+
tableau_auth = TSC.JWTAuth(jwt, site_id=site_url_name)
47+
"""
3948

4049
with server.auth.sign_in(tableau_auth):
4150
projects, pagination = server.projects.get()

samples/getting_started/3_hello_universe.py renamed to samples/getting_started/3_hello_content.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@ def main():
2323
# e.g https://my-server/#/this-is-your-site-url-name/
2424
site_url_name = "" # leave empty if there is no site name in the url (you are on the default site)
2525

26-
# 4
27-
username = "your-username-here"
28-
password = getpass.getpass("Your password:") # so you don't save it in this file
29-
tableau_auth = TSC.TableauAuth(username, password, site_id=site_url_name)
30-
31-
# OR instead of username+password, use a Personal Access Token (PAT) (required by Tableau Cloud)
32-
# token_name = "your-token-name"
33-
# token_value = "your-token-value-long-random-string"
34-
# tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site_url_name)
26+
# 4 - replace with your Personal Access Token values from the page 'My Account' on your Tableau site
27+
token_name = "your-token-name"
28+
token_value = "your-token-value-long-random-string"
29+
tableau_auth = TSC.PersonalAccessTokenAuth(token_name, token_value, site_id=site_url_name)
30+
31+
# (to log in with a username/password or JWT see example 2_hello_site.py))
3532

3633
with server.auth.sign_in(tableau_auth):
3734
projects, pagination = server.projects.get()

0 commit comments

Comments
 (0)
0