-
-
Save dlederle/f4c8d5d48631cc360df1c37d5c2a482b to your computer and use it in GitHub Desktop.
tableau trusted python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! python3 | |
import requests | |
import sys | |
# replace these with configData | |
tableauServer = 'http://localhost/' | |
tableauUsername = 'Robin' | |
workbookView = 'WorldIndicators/GDPpercapita' | |
workbookView2 = 'WorldIndicators/Countryranks' | |
worksheetSuffix = '.csv' | |
# getting trusted authentication for Tableau | |
# see http://onlinehelp.tableau.com/current/server/en-us/trusted_auth.htm | |
# for details on how to set up | |
wgserverURL = tableauServer + 'trusted/' | |
r = requests.post(wgserverURL, data={'username': tableauUsername}) | |
# status_code has the response code, text has the ticket string | |
if r.status_code == 200: | |
if r.text != '-1': | |
ticketID = r.text | |
else: | |
print("Tableau Server could not issue trusted ticket, for more information see \n ...ProgramData\Tableau\Tableau Server\data\tabsvc\logs\wgserver\production*.log and \n ...ProgramData\Tableau\Tableau Server\data\tabsvc\logs\vizqlserver\vizql*.log \nAlso check http://onlinehelp.tableau.com/current/server/en-us/trusted_auth_trouble_1return.htm") | |
sys.exit() | |
else: | |
print('Could not get trusted ticket with status code',str(r.status_code)) | |
url = wgserverURL + ticketID + '/views/' + workbookView + worksheetSuffix | |
print(url) | |
r = requests.get(url,allow_redirects=False) | |
#print (r.cookies['workgroup_session_id']) | |
print (r.cookies) | |
url2 = tableauServer + '/views/' + workbookView + worksheetSuffix | |
r2 = requests.get(url2,cookies=r.cookies) | |
print(r2.text) | |
url3 = tableauServer + '/views/' + workbookView2 + worksheetSuffix | |
r3 = requests.get(url3,cookies=r.cookies) | |
print(r3.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment