Closed
Description
Starting with v0.29 I notice many of my test scripts failing with an exception. It seems like a general problem rather than specific to one endpoint. Here's an example:
import tableauserverclient as TSC
tableau_auth = TSC.PersonalAccessTokenAuth(
"xxxxx",
"xxxxxxxxxx",
"",
)
server = TSC.Server("https://devplat.tableautest.com", use_server_version=True)
with server.auth.sign_in(tableau_auth):
all_wb, pagination_item = server.workbooks.get()
print("\nThere are {} workbooks: ".format(pagination_item.total_available))
for wb in all_wb:
print(wb.id, wb.name, wb.tags)
The script succeeds (printing workbooks), but ends with an exception like this:
Traceback (most recent call last):
File "/Users/bcantoni/github/server-client-python/getdatasources.py", line 14, in <module>
with server.auth.sign_in(tableau_auth):
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/auth_endpoint.py", line 27, in __exit__
self._callback()
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/endpoint.py", line 291, in wrapper
return func(self, *args, **kwargs)
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/auth_endpoint.py", line 85, in sign_out
self.post_request(url, "")
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/endpoint.py", line 248, in post_request
return self._make_request(
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/endpoint.py", line 165, in _make_request
self._check_status(server_response, url)
File "/Users/bcantoni/github/server-client-python/tableauserverclient/server/endpoint/endpoint.py", line 186, in _check_status
raise NotSignedInError(server_response.content, url)
tableauserverclient.server.endpoint.exceptions.NotSignedInError: (b'<?xml version=\'1.0\' encoding=\'UTF-8\'?><tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api https://help.tableau.com/samples/en-us/rest_api/ts-api_3_22.xsd"><error code="401002"><summary>Unauthorized Access</summary><detail>Invalid authentication credentials were provided.</detail></error></tsResponse>', 'https://10ax.online.tableau.com/api/3.22/auth/signout')
If I switch from using the with
statement to the older style, it works fine:
import tableauserverclient as TSC
tableau_auth = TSC.PersonalAccessTokenAuth(
"xxxx",
"xxxxxxx",
"",
)
server = TSC.Server("https://devplat.tableautest.com", use_server_version=True)
server.auth.sign_in(tableau_auth)
all_wb, pagination_item = server.workbooks.get()
print("\nThere are {} workbooks: ".format(pagination_item.total_available))
for wb in all_wb:
print(wb.id, wb.name, wb.tags)
Testing notes:
- I tested with same results on both Tableau Cloud and Server.
- This seems new to 0.29; switching back to 0.28 solves the issue.
- Git bisect points to Issue 1299 #1300 as the point this was introduced
- In server/endpoint/endpoint.py, changing
seconds = 0.05
back toseconds = 0
seems to fix it (but I'll admit I don't totally follow the changes in that PR)