Tableau tickets - POST to get a ticket returning the login form, not ticket ID

I can see that there are not many Tableau experts around StackOverflow, but maybe some of them have already encountered this problem and know this solution. I am a complete Noob at Tableau, so please forgive me if this question is insane. Thanks in advance!

System

Tableau installation method is located on the server separately from the web server. The application is written in PHP using CakePHP 2.2.0 stable.

10.0.0.10 - webserver 10.0.0.11 - tableau 

In order for the client to view the report created in Tableau, we use a reliable ticket verification system where the client is given a URL with a specific ticket. The client then uses this ticket to request the table server directly for the report.

Example:

  • GETS client http://example.com/reports/view/3 - internal 10.0.0.10.
  • Server POSTS up to 10.0.0.11 and requests a ticket to view client report 3
  • The Tableau server responds to the message with a number, for example. 987654321.
  • The server responds to the GET client on the page, including the ticket.
  • GETS Client http://tableau.example.com/trusted/987654321/view3
  • The Tableau server checks the client's IP address on the ticket and responds to the HTML report.

Problem

The problem is this: when the code asks for the ticket number of the table (steps 2 and 3 above), the Tableau server responds to the authentication page, not the ticket identifier. If I comment out the "target_site" parameter in the $ postdata array, the table does not respond to the login page and instead simply says "-1".

PHP code to create a trusted URL:

 <?php public function get_trusted_url($view = 'book2sheet1') { $email = $this->Auth->user(); $email = $email['Email']; //This email is registered as a Tableau user! $postdata = http_build_query( array( 'username' => $email, 'target_site' => 'oursite', //If I comment this line out, Tableau no longer returns an auth page and instead simply returns "-1" 'client_ip' => $_SERVER['REMOTE_ADDR'] ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $ticket = file_get_contents('http://10.0.0.11/trusted/', false, $context); if($ticket > 0) { return 'http://tableau.example.com/t/rg/trusted/' . $ticket . '/' .$view . '?:embed=yes&:comments=no&:toolbar=yes'; } else { echo 'failure'; //debug print_r($ticket); //debug - this prints out the auth page return false; } } 

Any help would be greatly appreciated! As I mentioned, I'm a complete noob in Tableau :)

Image of the returned html login dumped to the page using print_r('ticket')

tableau auth login page dump

Thanks!

+4
source share
2 answers

The first thing I would like to do is make sure Trusted Ticketing works in a vacuum. This http://ttrequest.notlong.com link will take you to a folder containing a simple HTML / JavaScript page that you can use to make sure everything is set up correctly. Then carefully look at your code.

Providing a value for target_site (even a zero-length string) is necessary as it tells us which Tableau site you are requesting a ticket for. Empty / zero line length = "Site by default", essentially.

I know very little PHP, but Tableau provides some sample code that I have used in the past. It does not use file_get_contents() to do the POST, but instead relies on http_parse_message() ... and it works for me:

  Function get_trusted_ticket_direct($server, $user, $targetsite) { $remote_addr = $_SERVER['REMOTE+ADDR']; $params = array( 'username' => $user, 'client_ip' => $remote_addr, 'target_site' => $targetsite ); $ticket= http_parse_message(http_post_fields("http://$server/trusted", $params))->body; if ($ticket > 0) { return $ticket; } else return 0; } 

I honestly don't know if file_get_contents () is considered a β€œbetter” approach than http_parse_message () in the PHP community (maybe someone can comment on this), but the code sample is simple, except for the fact that it is still does not contain a reference to the target_site parameter (as it was written before there was a multi-level service in Tableau).

Sample code can be found in C: \ Program Files (x86) \ Tableau \ Tableau Server \ 7.0 \ extras \ embedding \ php

Good luck

+3
source

You should use the site identifier, not the "name". Also, be careful that the name and identifier of the site are not the same, as this led to the return of the html page; make sure that the name and identifier of your site are different from each other!

+2
source

All Articles