如何通过python使用Tableau Server API进行身份验证?

时间:2016-03-14 23:09:02

标签: python authentication tableau tableau-online

我想使用Tableau Server API进行身份验证,以便我可以发布摘录。

但是,我遇到基本身份验证问题

from tableausdk.Server import *
from tableausdk import *

ServerAPI.initialize()
serverConnection = ServerConnection()
serverConnection.connect('http://online.tableau.com', 'email_address', 'password','https://10ay.online.tableau.com/#/site/example/views/site/Sheet1')

我收到以下错误:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2217, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1643, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Shippy/API/tableau_api.py", line 144, in <module>
    if __name__ == "__main__": main()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Shippy/API/tableau_api.py", line 140, in main
    print login_try_rest()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Shippy/API/tableau_api.py", line 136, in login_try_rest
    t.signin()
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 602, in signin
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 2796, in request_from_api
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 2773, in __make_request
IndexError: list index out of range

我很肯定我的用户名和密码是正确的,我也尝试了以下内容:

    ServerAPI.initialize()
    print ServerConnection().connect('http://online.tableau.com', 'username', 'password','')

我还尝试使用Tableau Rest API,this documentation

中概述了这一点。
t = TableauRestApi('http://online.tableau.com', 'username', 'password')
logger = Logger(u"log_file.txt")
t.enable_logging(logger)
t.signin() 

这给了我以下错误:

Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2217, in <module>
    globals = debugger.run(setup['file'], None, None)
  File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1643, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Shippy/API/tableau_api.py", line 154, in <module>
    t.signin()
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 602, in signin
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 2796, in request_from_api
  File "build/bdist.macosx-10.6-x86_64/egg/tableau_rest_api/tableau_rest_api.py", line 2773, in __make_request
IndexError: list index out of range

0 个答案:

没有答案