server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

[New functionality]: How to make request directly using token other than a TableauAuth or a PersonalAccessTokenAuth

Open mattholy opened this issue 1 year ago • 1 comments

Description

In a multi-thread occasion, sign in with PersonalAccessTokenAuth will always reset the token. Is there any way to store the token else where and use the token header directly without PersonalAccessTokenAuth again?

mattholy avatar Jun 19 '23 03:06 mattholy

Hello Mattholy,

You can use the token header details with site, user, token as below.

if name == 'main': # Authenticate Initially tableauAuth = TSC.TableauAuth(username, password) server1 = TSC.Server(server_name, http_options={"verify": False})
server1.auth.sign_in(tableauAuth) print(server1.users.get()[0][0]) site, user, token = server1.site_id, server1.user_id, server1.auth_token

# Reuse site, user, token
server2 = TSC.Server(server_name, http_options={"verify": False}) 
server2._set_auth(site, user, token)
print(server1.datasources.get()[0][0])

codespg avatar Aug 12 '23 18:08 codespg