tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.56k stars 598 forks source link

Unable to call custom function on enabling authetication #433

Closed biswabandhu21 closed 4 years ago

biswabandhu21 commented 4 years ago

I am getting following error

2020-07-22,11:04:14 [ERROR] (base_handler.py:base_handler:121): Responding with status=401, message="Invalid credentials provided.", info="Unauthorized request.", <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>>

I am able to connect to the service using the credentials but when I am calling the function I am getting error.

Complete log is below

2020-07-22,11:04:14 [DEBUG] (base_handler.py:base_handler:121): Querying https://localhost:9004/query/..., <> 2020-07-22,11:04:14 [DEBUG] (connectionpool.py:connectionpool:941): Starting new HTTPS connection (1): localhost:9004 2020-07-22,11:04:14 [INFO] (base_handler.py:base_handler:91): Call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360, Caller: ::1, Method: POST, URL: https://localhost:9004/query/voltageOathDecryptString 2020-07-22,11:04:14 [DEBUG] (base_handler.py:base_handler:121): Checking if need to handle authentication, <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [DEBUG] (base_handler.py:base_handler:121): Handling authentication, <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [DEBUG] (base_handler.py:base_handler:121): Checking request headers for authentication data, <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [INFO] (base_handler.py:base_handler:121): Authorization header not found, <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [DEBUG] (base_handler.py:base_handler:121): Processing POST for /query/..., <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [ERROR] (base_handler.py:base_handler:121): Failing with 401 for unauthorized request, <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [DEBUG] (state.py:state:596): Loading option 'Name' from section [Service Info]... 2020-07-22,11:04:14 [DEBUG] (state.py:state:616): Returning value 'TabPy Server' 2020-07-22,11:04:14 [ERROR] (base_handler.py:base_handler:121): Responding with status=401, message="Invalid credentials provided.", info="Unauthorized request.", <<call ID: 763b8f77-bc42-4af8-a0c4-d8e859611360>> 2020-07-22,11:04:14 [WARNING] (web.py:web:2250): 401 POST /query/voltageOathDecryptString (::1) 5.05ms 2020-07-22,11:04:14 [DEBUG] (connectionpool.py:connectionpool:442): https://localhost:9004 "POST /query/voltageOathDecryptString HTTP/1.1" 401 77 2020-07-22,11:04:14 [ERROR] (base_handler.py:base_handler:121): Responding with status=404, message="Error processing script", info="The endpoint you're trying to query did not respond. Please make sure the endpoint exists and the correct set of arguments are provided.", <> 2020-07-22,11:04:14 [WARNING] (web.py:web:2250): 404 POST /evaluate (172.26.81.119) 55.02ms

If I disable the password authetication , it works fine.

0golovatyi commented 4 years ago

@biswabandhu21

  1. Are you on Desktop or Server?
  2. How do you configure the connection?
  3. How do you connect to the service?
biswabandhu21 commented 4 years ago

@0golovatyi

  1. We are connecting to Tableau server and not using desktop

  2. Tried following command to setup connection between server and Tabpy if this is what you are asking. Not sure follwing is required tsm security vizql-extsvc-ssl enable --connection-type tabpy --extsvc-host my_tabpy_server --extsvc-port 9004 --extsvc-username --extsvc-password tsm pending-changes apply

  3. By following steps By Navigating to Help -->Settings and Performance -> Manage Analytics extension Connection ( from here we connect to tabpy, by specifying server name, uname and pwd)

0golovatyi commented 4 years ago

@biswabandhu21

A few more questions.

We are connecting to Tableau server and not using desktop

What version do you use?

tsm security vizql-extsvc-ssl enable --connection-type tabpy --extsvc-host my_tabpy_server --extsvc-port 9004 --extsvc-username --extsvc-password

This command only works for specific versions on Tableau Server - this is why I asked for version above. Starting from 2020.2 the connections are configured with admin UI, some useful information here - http://tabscifi.com/2020/05/multiple-analytics-extensions-connections-with-tableau-server-2020-2/.

By following steps By Navigating to Help -->Settings and Performance -> Manage Analytics extension Connection ( from here we connect to tabpy, by specifying server name, uname and pwd)

These steps are for Desktop, but you mentioned above you are not using Desktop.

biswabandhu21 commented 4 years ago

Our version is Tableau 2020.1

0golovatyi commented 4 years ago

@biswabandhu21 For 2020.1 Server these commands look right:

tsm security vizql-extsvc-ssl enable --connection-type tabpy --extsvc-host my_tabpy_server --extsvc-port 9004 --extsvc-username --extsvc-password
tsm pending-changes apply

However, as I mentioned above this step is for Desktop only:

By Navigating to Help -->Settings and Performance -> Manage Analytics extension Connection ( from here we connect to tabpy, by specifying server name, uname and pwd)

You also mentioned

I am able to connect to the service

So my question is how do you connect to the service?

biswabandhu21 commented 4 years ago

I am able to connect when authentication is disabled.

0golovatyi commented 4 years ago

@biswabandhu21 How do you connect?

biswabandhu21 commented 4 years ago

@0golovatyi

We tried from desktop with both authentication as well as non authentication. Its works fine. The issue we are facing is with the server version. We tried following commands

tsm security vizql-extsvc-ssl enable --connection-type tabpy --extsvc-host my_tabpy_server --extsvc-port 9004 --extsvc-username --extsvc-password tsm security maestro-tabpy-ssl enable --connection-type maestro-tabpy-secure -cf E:\Python\TabPy\ssl\.crt --tabpy-host --tabpy-port --tabpy-username --tabpy-password --tabpy-connect-timeout-ms 900000 tsm pending-changes apply

It ran but still getting the same error:

[ERROR] (base_handler.py:base_handler:121): Responding with status=401, message="Invalid credentials provided.", info="Unauthorized request."

I think tableau is not attaching the authorization header in post request

We followed below articles

https://help.tableau.com/v2019.2/server/en-us/cli_security_tsm.htm#tsm_security_vizql-extsvc-ssl-enable https://help.tableau.com/current/server/en-us/cli_security_tsm.htm#maestro-tabpy-ssl-enable

0golovatyi commented 4 years ago

@biswabandhu21

As I mentioned above server configuration instructions for analytics extensions are version-specific. For Tableau Server 2020.1 this is the documentation - https://help.tableau.com/v2020.1/server/en-us/cli_security_tsm.htm#tsm_security_vizql-extsvc-ssl-enable. However, the commands you provided should work, but I don't see you specifying username and password in the command (I understand you just removed those from the example you provided). Just to confirm your actual commands for Tableau Server look like this (specifically asking for < USERNAME > and < PASSWORD > parameters):

tsm security vizql-extsvc-ssl enable --connection-type tabpy --extsvc-host my_tabpy_server --extsvc-port 9004 --extsvc-username **<USERNAME>** --extsvc-password **<PASSWORD>**
tsm pending-changes apply
0golovatyi commented 4 years ago

@biswabandhu21 were you able to resolve the issue?

biswabandhu21 commented 4 years ago

@0golovatyi ,

No, its still pending. Looks like there is an issue with Tableau version we are using . It is not sending the correct authorization header to Tabpy. Its not working from both server as well as from desktop version. For now we have removed the authentication . We are planning to upgrade our Tableau to the latest version. Hopefully , it will fix the issue.

biswabandhu21 commented 4 years ago

@0golovatyi ,

one more thing we have seen in the logs. When we make test connection , log shows server hostname but when it call the function the logs show localhost. Not sure why .

0golovatyi commented 4 years ago

@biswabandhu21 Tableau supports auth for TabPy starting from 2019.4.2, some additional information about how to configure it here - http://tabscifi.com/2020/01/how-to-configure-tabpy-with-authentication-and-use-it-in-tableau/.

For the server name in logs do you mean TabPy logs and Tableau Server name in the logs? I'll check the behavior as soon as I can.

biswabandhu21 commented 4 years ago

I am taking about Tabpy logs. I will look into the link you shared. Thanks for your help.

0golovatyi commented 4 years ago

@biswabandhu21 TabPy 2.2.0 was just published - it has some auth improvements and bug fixes in it if you want to try.

RyanCalovich commented 3 years ago

@0golovatyi , @biswabandhu21 Did you guys ever solve this? I'm running into the same issue, with Tableau Server version 2020.2

0golovatyi commented 3 years ago

@RyanCalovich Yes, this was fixed. Note that configuring Tableau Server requires different steps for different versions.

Please open a new issue with repro steps.