tableau / server-client-python

A Python library for the Tableau Server REST API
https://tableau.github.io/server-client-python/
MIT License
655 stars 420 forks source link

Error Code 401002 Unauthorized Access at end of authentication loop or upon sign-out #1351

Closed jyoung-slalom closed 7 months ago

jyoung-slalom commented 7 months ago

Describe the bug When using the TableauServerClient library to make API requests in Python scripts, an error is returned at the end of each authentication loop.

The same error occurs if you attempt to bypass the loop and manually sign out.

If you forego the 'with' loop and exclude a server.auth.sign_out() function, the script will execute as intended.

Versions Details of your environment, including:

To Reproduce if using a script to get a list of users/groups from Tableau Server/Cloud, the following loop is initiated:

tableau_auth = tableau_authenticate(token_name, token_value, portal_url, site_id)

server = TSC.Server(portal_url)

server.add_http_options({'verify': False})

server.use_server_version()

with server.auth.sign_in(tableau_auth):

The same error occurs if you attempt to bypass the loop and manually sign out, e.g.:

server.auth.sign_in(tableau_auth)

server.auth.sign_out()

Results 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_19.xsd"><error code="401002"><summary>Unauthorized Access</summary><detail>Invalid authentication credentials were provided.</detail></error></tsResponse>', 'https://tscommunity.slalom.com//api/3.19/auth/signout')

jyoung-slalom commented 7 months ago

Fixed in TableauServerClient 0.30