Online links.

http://onlinehelp.tableau.com/current/server/en-us/trusted_auth_trouble_1return.htm

https://onlinehelp.tableau.com/current/online/en-us/embed_list.htm

https://onlinehelp.tableau.com/current/server/en-us/admin.htm

http://onlinehelp.tableau.com/current/server/en-us/trusted_auth_testing.htm

https://onlinehelp.tableau.com/current/server/en-us/trusted_auth_how.htm

https://onlinehelp.tableau.com/current/server/en-us/tabadmin.htm

http://kb.tableau.com/articles/issue/error-could-not-locate-unexpired-trusted-ticket

https://community.tableau.com/thread/170976?start=0&tstart=0

https://github.com/mitchbox/py-tableau/blob/master/application/__init__.py

Tableau API configuration from server to client

Commands

Set path of tableau server.

C:\Program Files\Tableau\Tableau Server\10.2\bin>

Set trusted host as per below.

tabadmin configure -o "c:\SomeFileName.yml"
tabadmin set wgserver.trusted_hosts "40.71.97.40,10.1.1.4"
tabadmin stop
tabadmin config
tabadmin start
tabadmin set wgserver.trusted_hosts -d
tabadmin set vizportal.rest_api.cors.enabled  true
tabadmin set wgserver.unrestricted_ticket true
tabadmin session.ipsticky true

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Xml;

namespace Test.Controllers
{
    public class TableauAPIController : Controller
    {
        // GET: NewsAndEvents
        public ActionResult Index()//Market Snapshot
        {
            string token=getToken();
            ViewBag.token = token;
            HttpContext.Response.Headers.Add("X-Tableau-Auth", token);
            return View();
        }
        public ActionResult Stocks()
        {
            string token = getToken();
            ViewBag.token = token;
            HttpContext.Response.Headers.Add("X-Tableau-Auth", token);
            return View();
        }
        public ActionResult IndustryEvents()
        {
            return View();
        }
        //Web.config Settings
            <appSettings>
                 <add key="TableauServer" value="http://datainsighthub.com:8000"/>
                 <add key="TableauServerUser" value="tabadmin"/>
            </appSettings>

          public string getAuthToken()
        {
            string url = System.Configuration.ConfigurationManager.AppSettings["TableauServer"];
            url = url + "/trusted";

            string user = System.Configuration.ConfigurationManager.AppSettings["TableauServerUser"];
            var postData = "username=" + user;
            var data = Encoding.ASCII.GetBytes(postData);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
            request.ContentLength = data.Length;
            request.Method = "POST";
            StreamWriter requestWriter = new StreamWriter(request.GetRequestStream());
            requestWriter.Write(postData);
            requestWriter.Close();
            HttpWebResponse response;
            response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream responseStream = response.GetResponseStream();
                string responseStr = new StreamReader(responseStream).ReadToEnd();
                return responseStr;
            }
            return null;
        }
        public string postXMLData(string destinationUrl, string requestXml)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
            byte[] bytes;
            bytes = System.Text.Encoding.ASCII.GetBytes(requestXml);
            request.ContentType = "text/xml; encoding='utf-8'";
            request.ContentLength = bytes.Length;
            request.Method = "POST";
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(bytes, 0, bytes.Length);
            requestStream.Close();
            HttpWebResponse response;
            response = (HttpWebResponse)request.GetResponse();
            if (response.StatusCode == HttpStatusCode.OK)
            {
                Stream responseStream = response.GetResponseStream();
                string responseStr = new StreamReader(responseStream).ReadToEnd();
                return responseStr;
            }
            return null;
        }

        public string getToken()
        {
            string url = "http://datainsighthub.com:8000/api/2.5/auth/signin";
            string xmlBody = "<tsRequest><credentials name = 'tabadmin' password = '******'> <site contentUrl = '' /> </credentials></tsRequest>";

           // string url = "https://us-east-1.online.tableau.com/api/2.5/auth/signin";
           // string xmlBody = "<tsRequest><credentials name = '[email protected]' password = 'bsnm234*'> <site contentUrl = 'bsnminc' /> </credentials></tsRequest>";
            var str = postXMLData(url, xmlBody);
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(str);  // suppose that str string contains the XML data. You may load XML data from a file too.
            string token = xml.GetElementsByTagName("credentials")[0].Attributes["token"].Value;

            return token;
        }
    }
}
//view 1:
             <script type='text/javascript' src='http://datainsighthub.com:8000/javascripts/api/viz_v1.js'>
                            </script>
                            <div class='tableauPlaceholder' style='width: 1463px; height: 695px;'>
                            <object class='tableauViz' width='1463' height='695' style='display:none;'>
                            <param name='host_url' value='http%3A%2F%2Fdatainsighthub.com%3A8000%2F' /> 
                                <param name="ticket" [email protected] />
                            <param name='site_root' value='&#47;t&#47;bi' />
                            <param name='name' value='TestWorkbook&#47;Dashboard4' />
                            <param name='tabs' value='no' />
                            <param name='toolbar' value='yes' />
                            <param name='showShareOptions' value='true' />
                            </object>
                            </div>
//view 2:
    @{
        string path = "http://datainsighthub.com:8000/trusted/" + @ViewBag.token;
    }
    <div class="panel-body" style="height:730px;display:none;" >
        <iframe src=@path width="800" height="600"></iframe>
    </div>

Pass token in view.

<div class='tableauPlaceholder' style='display:none;'>

    <script type='text/javascript' src='http://datainsighthub.com:8000/javascripts/api/viz_v1.js'>
    </script>
    <div class='tableauPlaceholder' style='width: 1462px; height: 704px;display:none;'>
        <object class='tableauViz' width='1462' height='704' style='display:none;'>
            <param name='host_url' value='http%3A%2F%2Fdatainsighthub.com%3A8000%2F' />
            <param name='site_root' value='' />
            <param name="ticket" [email protected] />
            <param name='name' value='testtableaureport&#47;Dashboard3' />
            <param name='tabs' value='yes' />
            <param name='toolbar' value='yes' />
            <param name='showShareOptions' value='true' />
        </object>
    </div>

</div>