8000 118 suppress insecurerequestwarning doc (#129) · SnarkyPapi/server-client-python@43d5088 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43d5088

Browse files
talvalinRussell Hay
authored and
Russell Hay
committed
118 suppress insecurerequestwarning doc (tableau#129)
* First draft of doc update * Second draft of doc update * Updated following Github discussion * Second revision based on discussion
1 parent 477366e commit 43d5088

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

docs/docs/sign-in-out.md

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Sign In and Out
33
layout: docs
44
---
5-
5+
## Signing in and out
66
To sign in and out of Tableau Server, call the `Auth.sign_in` and `Auth.sign_out` functions like so:
77

88
```py
@@ -18,22 +18,53 @@ server.auth.sign_in(tableau_auth)
1818
server.auth.sign_out()
1919
```
2020

21+
Alternatively, for short programs, consider using a `with` block:
22+
23+
```py
24+
import tableauserverclient as TSC
25+
26+
tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD')
27+
server = TSC.Server('http://SERVER_URL')
28+
29+
with server.auth.sign_in(tableau_auth):
30+
# Do awesome things here!
31+
32+
# No need to call auth.sign_out() as the Auth context manager will handle that on exiting the with block
33+
```
34+
2135
<div class="alert alert-info">
2236
<b>Note:</b> When you sign in, the TSC library manages the authenticated session for you, however it is still
2337
limited by the maximum session length (of four hours) on Tableau Server.
2438
</div>
2539

26-
27-
Alternatively, for short programs, consider using a `with` block:
40+
### Disabling certificate verification and warnings
41+
Certain environments may throw errors related to SSL configuration, such as self-signed certificates or expired certificates. These errors can be avoided by disabling certificate verification with ```add_http_options```:
2842

2943
```py
3044
import tableauserverclient as TSC
3145

3246
tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD')
3347
server = TSC.Server('http://SERVER_URL')
48+
server.add_http_options({'verify': False})
49+
```
3450

35-
with server.auth.sign_in(tableau_auth):
36-
# Do awesome things here!
51+
However, each subsequent REST API call will print an ```InsecureRequestWarning```:
52+
```
53+
InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
54+
InsecureRequestWarning)
55+
```
56+
57+
These warnings can be disabled by adding the following lines to your script:
58+
```py
59+
import requests
60+
from requests.packages.urllib3.exceptions import InsecureRequestWarning
61+
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
3762
```
3863

39-
The TSC library signs you out of Tableau Server when you exit out of the `with` block.
64+
### A better way to avoid certificate warnings
65+
Instead of disabling warnings and certificate verification to workaround issues with untrusted certificates, the best practice is to use a certificate signed by a Certificate Authority.
66+
67+
If you have the ability to do so, we recommend the following Certificate Authorities:
68+
* [GlobalSign](https://www.globalsign.com/en/)
69+
* [Let's Encrypt](https://letsencrypt.org/) - a free, automated, and open Certificate Authority
70+
* [SSL.com](https://www.ssl.com/)

0 commit comments

Comments
 (0)
0