Does anybody have any Trusted Authentication JavaScript Code Examples which you could let me see (specifically code which shows me how to get a ticket)? I am trying to set-up trusted authentication for our web developers and need some example code. Have looked in the extras folder on the server and found Java code, but it would be really helpful to get some JavaScript examples.
Thanks!
Here's the answer to my own question in C# / .NET (run as server side code) which was provided by my colleagues:
using System.IO;
using System.Net;
using System.Text;
using System.Web.Mvc;
using NewTableauProject.Models;
namespace NewTableauProject.Controllers
{
public class HomeController : Controller
{
private static string GetTableauAuthenticationTicket()
{
var user = "<username>"; //UserInformation.GetAuthenticatedUsername();
var request = (HttpWebRequest)WebRequest.Create("<servername>/trusted");
var encoding = new UTF8Encoding();
var postData = "username=" + user;
postData += "&target_site=<sitename>";
byte[] data = encoding.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
return new StreamReader(response.GetResponseStream()).ReadToEnd();
}
}
}