You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sign-in-out.md
+48-8Lines changed: 48 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,17 +10,16 @@ The first step to using the TSC library is to sign in to your Tableau Server (or
10
10
11
11
## Sign In
12
12
13
-
Signing in can be done two different ways:
13
+
Signing in through tsc and the REST API can be done several different ways - in most cases only some of these options will be available, depending on your server configuration. You can see details of all the underlying APIs for authentication in the [REST API documentation](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_authentication.htm).
14
14
15
-
* Personal Access Tokens - In most cases this is the preferred method because it improves security by avoiding the need to use or store passwords directly. Access tokens also expire by default if not used after 15 consecutive days. This option is available for Tableau Server 2019.4 and newer. Refer to [Personal Access Tokens](https://help.tableau.com/current/server/en-us/security_personal_access_tokens.htm) for more details.
16
-
* Username and Password - Direct sign in with account username and password.
17
-
18
-
Examples showing both of these cases are included below.
15
+
Examples for all supported methods are included below.
19
16
20
17
**Note:** When you sign in, the TSC library manages the authenticated session for you. However, the validity of the underlying credentials token is limited by the maximum session length set on your Tableau Server (2 hours by default).
21
18
22
19
### Sign in with Personal Access Token
23
20
21
+
In most cases this is the preferred method because it improves security by avoiding the need to use or store passwords directly. Access tokens also expire by default if not used after 15 consecutive days. This option is available for Tableau Server 2019.4 and newer. Refer to [Personal Access Tokens](https://help.tableau.com/current/server/en-us/security_personal_access_tokens.htm) for more details.
22
+
24
23
To sign in to Tableau Server or Tableau Cloud with a personal access token, you'll need the following values:
25
24
26
25
Name | Description
@@ -50,7 +49,10 @@ server.auth.sign_out()
50
49
51
50
### Sign in with Username and Password
52
51
53
-
To sign in to Tableau Server or Tableau Cloud with a username and password, you'll need the following values:
52
+
53
+
Direct sign in with account username and password. (This is no longer allowed for Tableau Cloud)
54
+
55
+
To sign in to Tableau Server with a username and password, you'll need the following values:
If you have Connected Apps enabled, you can create JSON Web Tokens and use them to authenticate over the REST API. To learn about Connected Apps, read the docs on [Tableau Connected Apps](https://help.tableau.com/current/server/en-us/security_auth.htm#connected-apps)
81
+
82
+
To sign in to Tableau Server or Tableau Cloud with a JWT, you'll need to have created a Connected App and generated the token locally (see [instructions to generate a JWT for your Connected App](https://help.tableau.com/current/server/en-us/connected_apps.htm#step-3-configure-the-jwt)):
SITENAME | The same as described for personal access tokens
90
+
SERVER_URL | The same as described for personal access tokens
91
+
92
+
This example illustrates using the above values to sign in with a JWT, do some operations, and then sign out:
93
+
94
+
```py
95
+
import tableauserverclient asTSC
96
+
97
+
tableau_auth =TSC.JWTAuth('JWT', 'SITENAME')
98
+
server =TSC.Server('https://SERVER_URL', use_server_version=True)
99
+
server.auth.sign_in(tableau_auth)
100
+
101
+
# Do awesome things here!
102
+
103
+
server.auth.sign_out()
104
+
```
105
+
106
+
107
+
## Impersonation (Tableau Server only)
108
+
On Tableau Server, users with a Server Administrator role can sign in through the REST API and 'impersonate' another user - this may be to validate server permissions, to investigate user problems, or to perform actions on behalf of the user. This can be done in tsc with any type of authentication by adding an extra parameter (`user_id_to_impersonate`) to the TableauAuth object creation
If you're connecting to a Tableau Server instance that uses self-signed or non-public SSL certificates, you may need to provide those as part of the sign in process. An example of this could be an on-premise Tableau Server that is using internally-generated SSL certificates. You may see an error like `SSL: CERTIFICATE_VERIFY_FAILED` if you connect with a Tableau Server but don't have the SSL certificates configured correctly.
79
119
@@ -126,7 +166,7 @@ As shown in the examples above, the sign out call is simply:
126
166
server.auth.sign_out()
127
167
```
128
168
129
-
## Simplify by using Python with block
169
+
## Simplify by using Python `with` block
130
170
131
171
The sign in/out flow can be simplified (and handled in a more Python way) by using the built-in support for the `with` block. After the block execution completes, the sign out is called automatically.
0 commit comments