3 Replies Latest reply on Feb 14, 2019 1:05 PM by Sandeep Reddy Alalla

    Trusted Ticket

    Sandeep Reddy Alalla

      Hi All,

       

      I am not a tableau developer. i am a web developer trying to integrate tableau with an Angular and .net core application. My front end calls an API in the backend which inturn talks to the tableau server to get the truted ticket.

      We added the server IpAddress to the tableau server as the trusted IP. below is the code i am using. i get a response from the server but it is not the ticket but a bunch of HTML

       

      public string GetTrustedTicket()

              {

                  try

                  {

      //                var url = $"https://devdoaenterprisebi.wi.gov/trusted/?:username={_tabConfig.Uid}&:target_site={_tabConfig.SiteId}";

                      var sbPostData  = new StringBuilder();

                      var        request = (HttpWebRequest)WebRequest.Create(_tabConfig.Endpoint);

       

       

                      dynamic encoding = new UTF8Encoding();

       

       

                      sbPostData.AppendFormat("username={0}", _tabConfig.Uid);

                      sbPostData.AppendFormat("&target_site={0}", _tabConfig.SiteId);

                      sbPostData.AppendFormat("&client_ip={0}", _tabConfig.IpAddress);

       

       

                      byte[] data = encoding.GetBytes(sbPostData.ToString());

       

       

                      request.Method        = "POST";

                      request.ContentType   = "application/x-www-form-urlencoded;charset=UTF-8";

                      request.ContentLength = data.Length;

       

       

                      using (Stream stream = request.GetRequestStream())

                      {

                          stream.Write(data, 0, data.Length);

                      }

       

       

                      var response = (HttpWebResponse)request.GetResponse();

       

       

                     return new StreamReader(response.GetResponseStream()).ReadToEnd();

                  }

                  catch (Exception ex)

                  {

                      throw new Exception("HttpWebRequest could not be created with Tableau API.");

                  }

              }

       

      Here is the HTML i got

       

      <!DOCTYPE html>

       

      <html>


      <head>

        <meta charset="UTF-8">

        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <title>Tableau Server Sign In</title>

        <script src="/jquery.js?6m6iytne3n8"></script>

        <script src="/underscore.js?6m6iytne3n8"></script>

        <script src="/embeddedCommonJade.js?6m6iytne3n8"></script>

        <style>.tb-large-button {

         line-height: 34px;

         padding: 12px 23px;

         font-size: 16px;

         margin-left: auto;

         margin-right: auto;

      }


      .tb-embedded-login-button {

         display: inline-block;

         background-color: rgb(53,92,128); /* desktopBlue */

         text-align: center;

         color: rgb(255,255,255);

         outline: 0;

         border-radius: 1px;

      }


      .tb-embedded-login-button:hover,

      .tb-embedded-login-button:focus {

         background-color: rgb(34,38,54); /* applicationBlue */

      }


      .tb-embedded-login-button:active {

         background-color: rgb(53,92,128); /* desktopBlue */

      }


      .tb-secondary-button {

        display: inline-block;

        text-decoration: underline;

      }


      .tb-secondary-button:hover {

        cursor: pointer;

      }


      .tb-container {

         text-align: center;

         border: 1px solid rgb(230,230,230);

         position: absolute;

         top: 0;

         left: 0;

         right: 0;

         bottom: 0;

         font-family: Arial, Helvetica, sans-serif;

         border-radius: 2px;


        /* Start off with display none. Change it when we know we won't redirect */

        display: none;

      }


      .tb-container-inner {

        position: absolute;

        top: 15%;

        right: 0;

        left: 0;

        bottom: 0;

      }


      .tb-logo,

      .tb-logo-container {

        margin: 0px auto 48px auto;

      }


      .tb-button-container {

        margin-bottom: 1em;

      }


      #not-working-link {

        display: none;

        font-size: 9px;

        color: rgb(54, 126, 156);

        text-decoration: none;

      }


      #AuthHelperBuildId,

      #AuthHelperLocSignInTo,

      #AuthHelperLocSignIn {

        display:none;

        visibility:hidden;

      }

      </style>

      </head>

      <script src="/js.cookie.js?6m6iytne3n8"></script><input id="AuthHelperBuildId" type="hidden" value="6m6iytne3n8"

        disabled aria-hidden><input id="AuthHelperLocSignInTo" type="hidden" value="Sign in to {SERVER_NAME}" disabled

        aria-hidden><input id="AuthHelperLocSignIn" type="hidden" value="Sign In" disabled aria-hidden>

      <script src="/embeddedAuthJade.js?6m6iytne3n8"></script>


      <body>

        <div class="tb-container">

        <div class="tb-container-inner">

        <div class="tb-logo-container"></div>

        <div class="tb-button-container"><a id="primary-auth" tabindex="0" role="button" class="tb-large-button tb-embedded-login-button"></a></div>

        <div class="tb-button-container"><a id="secondary-auth" tabindex="0" role="button" class="tb-secondary-button">Use

        your Tableau ID instead</a></div>

        <div class="tb-button-container"><a id="not-working-link" href="https://onlinehelp.tableau.com/current/online/en-us/to_signin.htm#sign-in-ie"

         target="_top">Sign in not working?</a></div>

        </div>

        </div>

      </body>


      </html>