2 Replies Latest reply on Dec 18, 2015 5:08 PM by Jeff D

    Does REST API token work as JS API ticket?

    Michael Bilow

      I'm trying to embed some viz from my tableau server into an external webpage

       

      I use my username and password to generate a token using the code from the REST API tutorial, then cut and paste the token into the trusted URL for the JS API like this:

       

      https://<tabserver>/trusted/<token>/t/<site>/views/<workbook>/<vizname>

       

      Is that correct, or does a specific JS ticket need to be generated?

       

      Assuming that's correct, there may be a problem farther downstream: I try to use that URL to get the viz using the JS API using the following code:

       

      var viz, workbook;

       

      // Initialize the javascript controls for Tableau
      window.onload=function() {

         var vizDiv = document.getElementById('viz');

         var vizURL = 'https://<tabserver>/trusted/<token>/t/<site>/views/<workbook>/<vizname>';

         var options = {

        width: '800',

        height: '600',

        hideToolbar: true,

        hideTabs: true,

        onFirstInteractive: function() {

        document.getElementById('sheetName').innerHTML=viz.getWorkbook().getActiveSheet().getName();

        }

        }

        viz = new tableauSoftware.Viz(vizDiv,vizURL, options);

      };

       

      <html>
      <head>
         <script type="text/javascript" src="https://<tabserver>/javascripts/api/tableau-2.min.js"></script>
        <script type="text/javascript" src="tableau_js_api_test.js"></script>
      </head>
      <body>
        <h2>Tableau JavaScript API</h2>
        <div id='viz'></div>
      </body>
      </html>

       

      However, when I do this, the tableau server always returns the same error:

      • Could not locate unexpired trusted ticket <token>

      Can someone advise?