This example demonstrates how to implement cookieless authentication for embedding ThoughtSpot using the Visual Embed SDK.
import { AppEmbed, AuthType, useInit, AuthStatus } from "@thoughtspot/visual-embed-sdk/react";
const getAuthToken = async (): Promise<string> => {
// Fetch a short-lived token from your backend
const response = await fetch("/api/thoughtspot-token");
return response.text();
};
const App = () => {
const authEE = useInit({
thoughtSpotHost: "https://your-instance.thoughtspot.cloud",
authType: AuthType.TrustedAuthTokenCookieless, // no third-party cookies needed
getAuthToken,
});
useEffect(() => {
authEE.current?.on(AuthStatus.SDK_SUCCESS, () => {
console.log("Cookieless auth successful");
});
}, []);
return <AppEmbed />;
};Open in StackBlitz
$ git clone https://github.com/thoughtspot/developer-examples
$ cd visual-embed/auth/cookieless
$ npm i
$ npm run dev
src
├── App.tsx -> Contains the embed code using @thoughtspot/visual-embed-sdk
├── services
│ └── token.ts -> Handles fetching auth token from backend
- React
- Typescript
- Web