I am having trouble getting a viz container to utilise a credentials token that I have successfully received as a response from tableau cloud.
The viz container I have embedded in my site previously works but after some time it will sign out, so I went through the process to create a PAT token and use this to generate a credentials token for ("X-tableau-auth": token) and confirmed the ALL OK with Postman. My Viz container utilises the javascript API provided by Tableau and automatically refreshes on a setInterval function call with the viz.refreshDataAsync() inside. \
**
This is the current html: **
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VMS Viewer</title>
<script type="text/javascript" src="https://online.tableau.com/javascripts/api/tableau-2.min.js"></script>
</head>
<body>
<button id="start">START</button>
<button id="stop">STOP</button>
<div id="vizContainer"></div>
<script type="text/javascript" src="./app.js"></script>
</body>
</html>
**Javascript linked to project: **
`//Declare constants/variables
let viz;
let refreshInterval;
const vizContainer = document.getElementById("vizContainer");
const url = "URL GOES HERE";
const options = {
height: "1080px",
width: "1920px",
toolbar: true
};
//Create VIZ container to display VMS content via URL given above
function initViz() {
viz = new tableau.Viz(vizContainer, url, options);
}
//Refresh VIZ container data with setInterval method and refreshDataAsync() method call
function refreshDataSource() {
console.log("Going to start refreshing..");
refreshInterval = setInterval(() => {
console.log("Refreshing....");
viz.refreshDataAsync();
}, 300000);
}
//Stop refresh and set interval to null
function stopRefresh() {
console.log("Stopping refresh");
clearInterval(refreshInterval);
}
//Event listeners for Start/Stop buttons
document.getElementById("start").addEventListener("click", refreshDataSource);
document.getElementById("stop").addEventListener("click", stopRefresh);
//Initialise Container in HTML
initViz();
and I changed it to try to use embedded API but isnt working either maybe I am missing something else.
Can anyone point me in the write direction with how to keep the embedded view but when it requests sign in to use the credentials token?
The request only loads when I remove the token as an attribute for the html tag.
Thanks!