简体   繁体   English

带有 PHP 的 Tableau 可信身份验证票证

[英]Tableau Trusted Authentication Ticket with PHP

I am trying to understand how the Trusted Authentication ticket is meant to work with PHP.我试图了解受信任的身份验证票证如何与 PHP 一起使用。 I've been looking up different questions and came up with this code我一直在寻找不同的问题并想出了这段代码

$url = 'https://tableau.godigitally.io/trusted/';     
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
curl_setopt($ch, CURLOPT_POST, true);     
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=" . $userid . ""); // define what you want to post    
$response = curl_exec($ch);   
curl_close($ch);   
//echo 'Test: ' . $response;  
echo '<iframe src=', $url, $ticket, 'views/Dashboard2_0/Dashboard1?', $urlparams, '" 
       width="700" height="400">   
  </iframe>';

But I get the following error when I run this code但是当我运行此代码时出现以下错误在此处输入图像描述

I have no idea where I'm going wrong.我不知道我哪里出错了。 I have confirmed that my server configuration is correct by using the testing techniques described in https://help.tableau.com/current/server/en-us/trusted_auth_testing.htm我已使用https://help.tableau.com/current/server/en-us/trusted_auth_testing.htm中描述的测试技术确认我的服务器配置是正确的

To Work with Tableau and web UI, the best way, you should add a Tableau js library to your web application and follow the steps要使用 Tableau 和 web UI,最好的方法是向 web 应用程序添加 Tableau js 库并按照步骤操作

  1. Generate the Ticket from tableau server call,从 tableau 服务器调用生成票证,

To generate the ticket from tableau server,first you should add your user to tableau server and follow the below steps要从 tableau server 生成票证,首先您应该将您的用户添加到 tableau server 并按照以下步骤操作

this is the code sample which you can use to generate the ticket这是您可以用来生成票证的代码示例

function getTabTicket(tableauServer, username, site){
      return new Promise((resolve,reject)=>{
              let url = new URL(tableauServer + '/trusted');
              let body = {
                          username: username,
                      };
              if (site) {
                          body['target_site'] = site;
                      }
              let postData = querystring.stringify(body);
                         
              let proto = http;
              if (url.protocol === 'https:') {
                          proto = https;
                      }
              let req = proto.request({
                          method: 'POST',
                          hostname: url.hostname,
                          port:url.port,
                          path: '/trusted',
                          headers: {'Content-Type': 'application/x-www-form-urlencoded'}
                      }, function (response) {
                              let ticketData = '';
                              response.on('data', function (chunk) {
                                          ticketData += chunk;
                                      });
                              response.on('end', function () {
                                          let contents = {ticket: ticketData};
                                          resolve(contents);
                                      });
                          });
              req.on('error', function (error) {
                        reject(error);
                        console.log('ERROR: ' + error);
                      });
              req.write(postData);
              req.end();
            })
}

You can check this library which is open source you can use to generate the Ticket.您可以查看这个开源库,您可以使用它来生成票证。

https://github.com/aalteirac/jwt-tableau-broker https://github.com/aalteirac/jwt-tableau-broker

https://anthony-alteirac.medium.com/tableau-trusted-authentication-the-ticket-broker-cloud-friendly-709789942aa3 https://anthony-alteirac.medium.com/tableau-trusted-authentication-the-ticket-broker-cloud-friendly-709789942aa3

After generating Ticket, you have to call the tableau server to get the report.生成 Ticket 后,您必须调用 tableau server 来获取报告。

I am using js library for that.我正在为此使用 js 库。

Now 2 step is include js using NPM or by reference现在第 2 步是使用 NPM 或通过引用包含 js

and then you can call the function然后你可以打电话给 function

var tableuReport = new tableau.Viz(this.reportContainerDiv, fullTableauDashboardUrl, Constants.tableauReportUISettings); var tableuReport = new tableau.Viz(this.reportContainerDiv, fullTableauDashboardUrl, Constants.tableauReportUISettings);

reportContainerDiv // the div element in which you have to render the component reportContainerDiv // 必须在其中呈现组件的 div 元素

fullTableauDashboardURL = {tableau_server_url}+"trusted"/{ticektId}/reportsuburl // the tableau URL it is in the format fullTableauDashboardURL = {tableau_server_url}+"trusted"/{ticektId}/reportsuburl // 表格 URL 格式为

for example your, tableau_server_url = "https://tableau-dev-abc.com" tableauDashboardUrl = "#/site/CovidApp/views/IndiaReport/IndiaReport_v2?:iid=1/"例如,您的 tableau_server_url = "https://tableau-dev-abc.com" tableauDashboardUrl = "#/site/CovidApp/views/IndiaReport/IndiaReport_v2?:iid=1/"

ticketId = "fjdjadheuihrieywfiwnfih" ticketId = "fjdjadheuihrieywfiwnfih"

So your final URL will be like PS:- fullTableauDashboardUrl.replace("#/site", "t");所以你最终的 URL 会像 PS:- fullTableauDashboardUrl.replace("#/site", "t"); we have to replace the #/site to t我们必须将#/site 替换为 t

fullTableauDashboardUrl = "https://tableau-dev-abc.com/trusted/fjdjadheuihrieywfiwnfih/t/CovidApp/views/IndiaReport/IndiaReport_v2?:iid=1 fullTableauDashboardUrl = "https://tableau-dev-abc.com/trusted/fjdjadheuihrieywfiwnfih/t/CovidApp/views/IndiaReport/IndiaReport_v2?:iid=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM