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

Error server.auth.sign_in(tableau_auth)

Open chrissalter opened this issue 9 years ago • 6 comments

Hello All!

I'm having some trouble with signing in. I copied the example code from https://tableau.github.io/server-client-python/docs/ using the sample code on the "Get Started" section. Below is nearly the same from the website aside from the variables assigned. Is it an issue with a Version of ElementTree or am i missing something obvious?

import tableauserverclient as TSC

tableau_auth = TSC.TableauAuth("[email protected]", "blahpass1234") server = TSC.Server("http://pretendtabserver12345.com/#/site/Chris/projects")

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 "", line 22, in File "/usr/local/lib/python2.7/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 107, in wrapper return func(self, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/tableauserverclient/server/endpoint/auth_endpoint.py", line 31, in sign_in parsed_response = ET.fromstring(server_response.content) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1311, in XML parser.feed(text) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1653, in feed self._raiseerror(v) File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1517, in _raiseerror raise err xml.etree.ElementTree.ParseError: must not undeclare prefix: line 1, column 15 [Finished in 0.456s]

chrissalter avatar Sep 22 '17 21:09 chrissalter

Hey @chrissalter

The issue is that the url you should be using in your example is "http://pretendtabserver12345.com".

If you need to log into a specific site, then the TableauAuth object has an optional parameter called site_id, and you'd pass in "Chris" as that argument to the TableauAuth object. Like this:

tableau_auth = TSC.TableauAuth("[email protected]", "blahpass1234", site_id="Chris")
server = TSC.Server("http://pretendtabserver12345.com/")

graysonarts avatar Sep 22 '17 21:09 graysonarts

Thanks man worked like a charm!

chrissalter avatar Sep 22 '17 22:09 chrissalter

Hi,

I am getting the similar error when I try to login the tableau server.My script is below

_import tableauserverclient as TSC tableau_auth = TSC.TableauAuth('username', 'passwd') server = TSC.Server('http://tabl.server.com')

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])_

and I am getting the following error

Traceback (most recent call last): File "first.py", line 6, in with server.auth.sign_in(tableau_auth): File "/opt/python-base-2.7/lib/python2.7/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 108, in wrapper return func(self, *args, **kwargs) File "/opt/python-base-2.7/lib/python2.7/site-packages/tableauserverclient/server/endpoint/auth_endpoint.py", line 32, in sign_in self._check_status(server_response) File "/opt/python-base-2.7/lib/python2.7/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 55, in _check_status raise ServerResponseError.from_response(server_response.content, self.parent_srv.namespace) File "/opt/python-base-2.7/lib/python2.7/site-packages/tableauserverclient/server/endpoint/exceptions.py", line 17, in from_response parsed_response = ET.fromstring(resp) File "/opt/python-base-2.7/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML parser.feed(text) File "/opt/python-base-2.7/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed self._raiseerror(v) File "/opt/python-base-2.7/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror raise err xml.etree.ElementTree.ParseError: mismatched tag: line 11, column 2

I have tried this with python3.6 but no luck.

please help me in fixing this.

sasimachi avatar Mar 18 '18 18:03 sasimachi

Can you open a separate issue for this? Also, can you include the full text of the result that is coming back from the server? You can turn on requests logging by following the instructions here: http://docs.python-requests.org/en/master/api/#api-changes

Also, can you let me know which version of the Tableau server you are hitting?

graysonarts avatar Mar 18 '18 18:03 graysonarts

oops, meant to tag @sasimachi on the above response

graysonarts avatar Mar 18 '18 18:03 graysonarts

download the source code from the pip repo: https://pypi.org/project/tableauserverclient/#files

miladdfo avatar Sep 07 '18 00:09 miladdfo