tableau / server-client-python

A Python library for the Tableau Server REST API

Home Page:https://tableau.github.io/server-client-python/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jyoung-slalom opened this issue · comments

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:

  • Tableau Server version: 20231.23.0511.1508
  • Tableau Cloud version: 20241.24.0122.1720
  • Python version: 3.12.0 64-bit
  • TSC library version: 0.29

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')

Fixed in TableauServerClient 0.30