Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion samples/create_extract_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def main():

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=False)
server.add_http_options({"verify": False})
server.use_server_version()
with server.auth.sign_in(tableau_auth):
# Monthly Schedule
Expand Down
2 changes: 1 addition & 1 deletion samples/create_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
# this code shows 3 different error codes that mean "resource is already in collection"
# 409009: group already exists on server
Expand Down
2 changes: 1 addition & 1 deletion samples/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, http_options={"verify": False})
server = TSC.Server(args.server)

server.use_server_version()
with server.auth.sign_in(tableau_auth):
Expand Down
1 change: 0 additions & 1 deletion samples/create_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def main():

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=False)
server.add_http_options({"verify": False})
server.use_server_version()
with server.auth.sign_in(tableau_auth):
# Hourly Schedule
Expand Down
2 changes: 1 addition & 1 deletion samples/create_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
# this code shows 2 different error codes for common mistakes
# 400013: Invalid site role
Expand Down
2 changes: 1 addition & 1 deletion samples/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
print("Connected")
if args.workbook:
Expand Down
2 changes: 1 addition & 1 deletion samples/filter_sort_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
logging.basicConfig(level=logging_level)

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
group_name = "SALES NORTHWEST"
# Try to create a group named "SALES NORTHWEST"
Expand Down
11 changes: 11 additions & 0 deletions samples/getting_started/1_hello_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ def main():
# This is the domain for Tableau's Developer Program
server_url = "https://10ax.online.tableau.com"
server = TSC.Server(server_url)

# OPTIONAL, FOR A TEST SERVER ONLY: turn off certificate verification.
# If your test server uses a self-signed certificate, requests fail with
# SSL: CERTIFICATE_VERIFY_FAILED. Turning verification off lets anyone between
# you and the server read or change the traffic, including your credentials,
# so never do this for a production server. Prefer giving TSC the server's
# certificate instead, see
# https://tableau.github.io/server-client-python/docs/sign-in-out#handling-ssl-certificates-for-tableau-server
# To opt in, uncomment the next line:
# server.add_http_options({"verify": False})

print(f"Connected to {server.server_info.baseurl}")
print(f"Server information: {server.server_info}")
print("Sign up for a test site at https://www.tableau.com/developer")
Expand Down
2 changes: 1 addition & 1 deletion samples/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main():
incremental = True

tableau_auth = TSC.PersonalAccessTokenAuth(args.token_name, args.token_value, site_id=args.site)
server = TSC.Server(args.server, use_server_version=True, http_options={"verify": False})
server = TSC.Server(args.server, use_server_version=True)
with server.auth.sign_in(tableau_auth):
if args.resource_type == "workbook":
# Get the workbook by its Id to make sure it exists
Expand Down
5 changes: 1 addition & 4 deletions tableauserverclient/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import requests
import threading
import urllib3
import ssl
import weakref

Expand Down Expand Up @@ -260,10 +259,8 @@ def __repr__(self):

def add_http_options(self, options_dict: dict):
try:
options_dict.keys() # reject non-mappings that dict.update would accept, such as lists of pairs
self._http_options.update(options_dict)
if "verify" in options_dict.keys() and self._http_options.get("verify") is False:
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# would be nice if you could turn them back on
except Exception as be:
# expected errors on invalid input:
# 'set' object has no attribute 'keys', 'list' object has no attribute 'keys'
Expand Down
9 changes: 9 additions & 0 deletions test/http/test_http_requests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import pytest
import tableauserverclient as TSC
import requests
Expand Down Expand Up @@ -70,6 +72,13 @@ def test_http_options_skip_ssl_works():
server.add_http_options(http_options)


def test_http_options_skip_ssl_leaves_warning_filters_alone():
filters_before = list(warnings.filters)
server = TSC.Server("http://fake-url")
server.add_http_options({"verify": False})
assert warnings.filters == filters_before


def test_http_options_multiple_options_works():
http_options = {"verify": False, "birdname": "Parrot"}
server = TSC.Server("http://fake-url")
Expand Down
Loading