7 Replies Latest reply on Apr 15, 2019 5:19 AM by Bhavana Khairnar

    Trusted Ticket with Python and Perl

    Andre Oliveira

      Hi everyone,


      I am trying to retrieve a trusted ticket using Perl. I've done it already using this Python script and it works, its very simple:


      #! python3 
      import requests   
      import sys
      import urllib3
      import getpass
      # disable SSL certificate warning
      from requests.packages.urllib3.exceptions import InsecureRequestWarning
      # configData   
      tableauServer = 'MYSERVER'   
      tableauUsername = MYUSER     
      # get trusted authentication for Tableau Server     
      wgserverURL = tableauServer + 'trusted/'
      r = requests.post(wgserverURL, data={'username': tableauUsername}, verify=False)   
      # validate the ticket
      # status_code has the response code, text has the ticket string   
      if r.status_code == 200:   
          if r.text != '-1':   
              ticketID = r.text   
              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")   
          print('Could not get trusted ticket',str(r.status_code)) 



      I wrote a simple script in Perl code, however it doesn't work. What is the problem? Can you help me?


      use HTTP::Request::Common qw(POST);
      use LWP::UserAgent;
      # bypass ssl certificate verification
      # create a user agent object
      $ua = LWP::UserAgent->new;
      #set HTTP request
      my $req = POST 'MYSERVER',
                      [ 'Username' => 'MYUSER'];
      # pass request to the user agent and get a response back
      my $resp = $ua->request($req);
      # check the outcome of the response
      if ($resp->is_success) {
          my $message = $resp->decoded_content;
          print "Received reply: $message\n";
      else {
          print "HTTP POST error code: ", $resp->code, "\n";
          print "HTTP POST error message: ", $resp->message, "\n";


      Thanks in advance.



      Best Regards,


      Andre Oliveira