Created
October 8, 2015 19:56
-
-
Save r-wheeler/23b4b94203fcf2f23fea 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
@r-wheeler But here you are passing in the tableau username, ideally in a web app how would you pass in the tableau username dynamically?
In my web app, I have auth0 authentication implemented - so the auth0 login page shows up and the user logs in using their auth0 credentials. Now would the users have to enter the tableau username as well before I can do the Trusted Authentication - or is there another way to get the tableau usernames