Cardata Don
07/02/2026, 2:57 PMAnswer Overflow
07/02/2026, 2:57 PMspotter-code
07/02/2026, 2:57 PMjavascript
import {
init,
AuthType,
EmbedEvent,
AuthFailureType,
LiveboardEmbed,
} from "@thoughtspot/visual-embed-sdk";
init({
thoughtSpotHost: "https://<your-ts-host>",
authType: AuthType.TrustedAuthToken, // or TrustedAuthTokenCookieless
autoLogin: true,
getAuthToken: async () => {
// Your backend should return a fresh TS login token for the current app user
const res = await fetch("/api/thoughtspot/token", { credentials: "include" });
if (!res.ok) throw new Error("Failed to fetch ThoughtSpot token");
return res.text();
},
});
const embed = new LiveboardEmbed("#ts-embed", {
liveboardId: "<liveboard-guid>",
});
embed.on(EmbedEvent.AuthFailure, async (payload) => {
// payload?.authFailureType can be EXPIRY
if (payload?.authFailureType === AuthFailureType.EXPIRY) {
// Optional: log/telemetry. SDK refresh flow is already triggered with autoLogin + getAuthToken.
console.warn("ThoughtSpot auth/session expired; refresh flow triggered.");
}
});
embed.render();
What matters most operationally:
- autoLogin: true so SDK proactively renews before expiry.
- getAuthToken or authEndpoint must always return a valid fresh token for the currently logged-in host-app user.
- For cookieless (AuthType.TrustedAuthTokenCookieless), token lifecycle is even more critical because token is used on subsequent requests.
- Keep host-app session lifetime and TS token issuance policy aligned (avoid host app still logged-in while token service denies renewal).
Suggestions:
- Add telemetry around EmbedEvent.AuthFailure and token endpoint failures (HTTP status, latency, user ID hash) to confirm whether drop-offs are expiry vs backend issues.spotter-code
07/02/2026, 2:57 PMTrustedAuthToken), short token validity is okay because token is one-time for session creation; with cookieless, request longer validity.
- Ensure your token service cannot be called by arbitrary clients to mint tokens for other users.
- If users still see logout behavior with autoLogin, check browser cookie constraints (3rd-party cookie behavior) and consider moving to cookieless auth.
Docs:
- Trusted auth SDK (autoLogin, token fetch flow): https://developers.thoughtspot.com/docs/trusted-auth-sdk#_overview
- Token request service + token expiry behavior: https://developers.thoughtspot.com/docs/trusted-auth-token-request-service#_v2_token
- Auth failure enum (EXPIRY): https://developers.thoughtspot.com/docs/Enumeration_AuthFailureType#_expiry
- Auth overview: https://developers.thoughtspot.com/docs/embed-authyuichirio_ha
07/03/2026, 10:22 AMltang_cd
07/06/2026, 7:26 PMyuichirio_ha
07/08/2026, 5:13 AMCardata Don
07/29/2026, 1:12 PMCardata Don
07/29/2026, 1:12 PM