1
1
####
2
2
# 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
6
5
#
6
+ # To make it easy to run, it doesn't take any arguments - you need to edit the code with your info
7
7
####
8
8
9
9
import getpass
@@ -25,17 +25,26 @@ def main():
25
25
# e.g https://my-server/#/site/this-is-your-site-url-name/not-this-part
26
26
site_url_name = "" # leave empty if there is no site name in the url (you are on the default site)
27
27
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
+ """
30
37
username = "your-username-here"
31
38
password = getpass.getpass("Your password:") # so you don't save it in this file
32
39
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
+ """
39
48
40
49
with server .auth .sign_in (tableau_auth ):
41
50
projects , pagination = server .projects .get ()
0 commit comments