tableau / server-client-python

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

Tableau ServerClient (error server.auth.sign_in(tableau_auth) #404

Closed saurabhkumar004 closed 5 years ago

saurabhkumar004 commented 5 years ago

Hi Everyone, i am very new to Rest API. I am trying to connect to my tableau server but getting below errors. I tried using http://server.com as well as server.add_http_options({'verify': False}). But it is not working.

Please help me in understanding the issue. code and error given below with both methods:

import tableauserverclient as TSC

tableau_auth = TSC.TableauAuth('Username', 'Password') server = TSC.Server('http://sau.com) server.add_http_options({'verify': False})

with server.auth.sign_in(tableau_auth): all_datasources, pagination_item = server.datasources.get() print("\nThere are {} datasources on site: ".format(pagination_item.total_available)) print([datasource.name for datasource in all_datasources])

Traceback (most recent call last): File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 159, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection raise err File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen chunked=chunked) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request conn.request(method, url, **httplib_request_kw) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1016, in _send_output self.send(msg) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 956, in send self.connect() File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 181, in connect conn = self._new_conn() File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connection.py", line 168, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x03630BB0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\util\retry.py", line 398, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='Server address', port=80): Max retries exceeded with url: /api/2.3/auth/signin (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x03630BB0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\skumar\Desktop\Sample1.py", line 8, in with server.auth.sign_in(tableau_auth): File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 114, in wrapper return func(self, *args, kwargs) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tableauserverclient\server\endpoint\auth_endpoint.py", line 30, in sign_in self.parent_srv.http_options) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 581, in post return self.request('POST', url, data=data, json=json, kwargs) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 533, in request resp = self.send(prep, send_kwargs) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='Server adress', port=80): Max retries exceeded with url: /api/2.3/auth/signin (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x03630BB0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))

import tableauserverclient as TSC

tableau_auth = TSC.TableauAuth('UserName', 'Password') server = TSC.Server('https://sau.com') server.add_http_options({'verify': False})

with server.auth.sign_in(tableau_auth): all_datasources, pagination_item = server.datasources.get() print("\nThere are {} datasources on site: ".format(pagination_item.total_available)) print([datasource.name for datasource in all_datasources])

C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning) Traceback (most recent call last): File "C:\Users\skumar\Desktop\Sample1.py", line 8, in with server.auth.sign_in(tableau_auth): File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 114, in wrapper return func(self, *args, **kwargs) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tableauserverclient\server\endpoint\auth_endpoint.py", line 32, in sign_in self._check_status(server_response) File "C:\Users\skumar\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 66, in _check_status raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace) tableauserverclient.server.endpoint.exceptions.ServerResponseError:

    401001: Signin Error
            Error signing in to Tableau Server
shinchris commented 5 years ago

The last error you got (401001) occurs when either the username or the password is incorrect for the site and server you are trying to sign in to, or if the specified site does not exist.

saurabhkumar004 commented 5 years ago

Hi @shinchris , thank you for your reply. I can sign on the server using the same server name, username and password by web, that I am using in this python script, but through python script I am facing this problem. Is it may be because our server is using SAML Authentication?

shinchris commented 5 years ago

Ah yes, unfortunately, TSC and the REST API does not support SAML authentication.

ivmonnier commented 5 years ago

Hello, I have sort of the same problem. I have a script which worked fine (until version 2018.3). I upgraded to 2019.1.1 and I can't sign in. My server is not using SSO.

Here is my script (I am server admin): import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('mylogin', 'mypsw') server = TSC.Server('http://myserver.fr') server.add_http_options({'verify': False}) -- (I added that but changes nothing) server.auth.sign_in(tableau_auth)

and here is the error:

Traceback (most recent call last): File "", line 6, in File "C:\Python36\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 114, in wrapper return func(self, *args, **kwargs) File "C:\Python36\lib\site-packages\tableauserverclient\server\endpoint\auth_endpoint.py", line 32, in sign_in self._check_status(server_response) File "C:\Python36\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 66, in _check_status raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace) tableauserverclient.server.endpoint.exceptions.ServerResponseError: 401001: Erreur de connexion Erreur lors de la connexion à Tableau Server

Thanks for your help

Ivan

ivmonnier commented 5 years ago

I have installed Tableau Server 2018.3.3 and my script works perfectly. It is obviously linked to 2019. Hope it helps.

Ivan

ivmonnier commented 5 years ago

I don't understand. I tried again against Tableau server 2019.1, and it works now, though I did not change anything. I am sorry for this spam.

Ivan

saurabhkumar004 commented 5 years ago

Hi @ivmonnier , I am currently using tableau server 2018.3, but not able to sign in. I am currently using SAML on my server. I think using SAML might be cause of error in my case, but I am not sure. Please message me here if you find some solution to it. @shinchris - Hi Chris, can this problem occur if API is DISABLE on Tableau server, or is it due to using SAML only?

shinchris commented 5 years ago

It's due to using SAML only. If the REST API is disabled on Tableau Server, it would throw a 404 not found error.

cycoo618 commented 5 years ago

I have spent the whole morning on figuring out the same issue, and finally found the solution. It seems Tableau didn't update the documentation on their own website.

Add site_id, it works for me: tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD', site_id='CONTENTURL')

irwando commented 5 years ago

Closing this issue as it seems all related conversation is resolved:

Nwakanwa commented 5 years ago

C:\Users\Admin\Desktop\SQL\tableauserver\venv\Scripts\python.exe C:/Users/Admin/Desktop/SQL/tableauserver/tableauserver.py Traceback (most recent call last): File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 70, in _check_status raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\exceptions.py", line 17, in from_response parsed_response = ET.fromstring(resp) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\xml\etree\ElementTree.py", line 1314, in XML parser.feed(text) xml.etree.ElementTree.ParseError: mismatched tag: line 6, column 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/Admin/Desktop/SQL/tableauserver/tableauserver.py", line 6, in with server.auth.sign_in(tableau_auth): File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 121, in wrapper return func(self, *args, **kwargs) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\auth_endpoint.py", line 32, in sign_in self._check_status(server_response) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 73, in _check_status raise NonXMLResponseError(server_response.content) NameError: name 'NonXMLResponseError' is not defined

Process finished with exit code 1

Nwakanwa commented 5 years ago

Help I'm getting this error

Nwakanwa commented 5 years ago

C:\Users\Admin\Desktop\SQL\tableauserver\venv\Scripts\python.exe C:/Users/Admin/Desktop/SQL/tableauserver/tableauserver.py Traceback (most recent call last): File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 70, in _check_status raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\exceptions.py", line 17, in from_response parsed_response = ET.fromstring(resp) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\xml\etree\ElementTree.py", line 1314, in XML parser.feed(text) xml.etree.ElementTree.ParseError: mismatched tag: line 6, column 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/Admin/Desktop/SQL/tableauserver/tableauserver.py", line 6, in with server.auth.sign_in(tableau_auth): File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 121, in wrapper return func(self, *args, **kwargs) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\auth_endpoint.py", line 32, in sign_in self._check_status(server_response) File "C:\Users\Admin\Desktop\SQL\tableauserver\venv\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 73, in _check_status raise NonXMLResponseError(server_response.content) NameError: name 'NonXMLResponseError' is not defined

Process finished with exit code 1

kykrueger commented 3 years ago

It is now possible to create a token for sign-in. https://github.com/tableau/server-client-python/issues/441#issuecomment-605088483

but it is unclear if such a token may be created by a SAML user.