Generating Tableau Trusted Tickets with curl or Python?
Question: I'm working on a portal site that will use Tableau Trusted Ticket
authentication ([as described
here](http://onlinehelp.tableausoftware.com/current/server/en-
us/trusted_auth_how.htm)), but having some trouble generating tickets.

One thing I wanted to verify before continuing development was that the web
server I'll be using has been properly white-listed for generating Trusted
Ticket requests.

I've run the white-listing command as described, but my PHP developer's code
keeps returning `-1`, indicating failure.

If all Tableau needs to generate and return a Trusted Ticket code is an HTTP
POST, I figure I should be able to test this by curl. I'm a little surprised
it's not suggested as a troubleshooting step, given how many web servers are
Linux-based.

Does anyone know the proper way to send a test POST in order to generate a
ticket, just to verify the white-listing? Since I have some little familiarity
with curl and Python, I've tried those (python using the requests module) with
no luck.

curl version:

    
    
    curl --data "username=exampleuser" http://webserver.example.com/trusted
    

Python version:

    
    
    import requests
    url = "http://webserver.example.com/trusted"
    postdata = "username=exampleuser"
    r = requests.post(url, postdata)
    print r.text
    

Both of these return a `-1`, which could just be that the white-listing failed
somehow, or could be that these are not properly formatted requests. Has
anyone tried something similar and met with success?

Conversely, does anyone have the cleartext string of what a correct `POST`
request should look like for this?

There is a useful chunk of HTML and JavaScript [over
here](http://kb.tableausoftware.com/articles/knowledgebase/testing-trusted-
authentication), with which I have been able to successfully generate tickets,
but since it's JavaScript-based I haven't figured a way to run it on my
headless webserver or capture the request it sends for analysis.


Answer: So first of all, when working with verbs using curl, you have to use `-X
VERBNAME`, e.g.,

    
    
    ~# curl -X POST http://httpbin.org/post
    {
      "url": "http://httpbin.org/post",
      "data": "",
      "json": null,
      "args": {},
      "form": {},
      "origin": "127.0.0.1",
      "headers": {
        "User-Agent": "curl/7.19.6 (x86_64-unknown-linux-gnu) libcurl/7.19.6 OpenSSL/0.9.8n zlib/1.2.3 libidn/1.5",
        "Connection": "close",
        "Accept": "*/*",
        "Content-Length": "0",
        "Host": "httpbin.org"
      },
      "files": {}
    }
    

Second of all, with the parameter being mentioned I would try these
variations:

    
    
    import requests
    
    # Variation 1
    r = requests.post(url, data={'username': 'exampleuser'})
    
    # Variation 2
    r = requests.post(url, params={'username': 'exampleuser'})
    
    # Followed by these lines
    print r.status_code
    print r.text
    

The equivalents in cURL should look something like this:

    
    
    # Variation 1 equivalent
    curl --data='username=exampleuser' -X POST http://httpbin.org/post
    
    # Variation 2 equivalent
    curl -X POST http://httpbin.org/post?username=exampleuser
    

I'm guessing by the second line that this is supposed to be an
`application/x-www-form-urlencoded` `POST` request so the first variations of
both should work. I'm not at all familiar with tableau though, so I can't
guarantee either will work.

