Skip to content

Latest commit

 

History

History

README.md

cookieless-embed

This example demonstrates how to implement cookieless authentication for embedding ThoughtSpot using the Visual Embed SDK.

Key Usage

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 />;
};

Demo

Open in StackBlitz

Documentation

Run locally

$ git clone https://github.com/thoughtspot/developer-examples
$ cd visual-embed/auth/cookieless
$ npm i
$ npm run dev

Code Structure

Source Code

src
├── App.tsx    -> Contains the embed code using @thoughtspot/visual-embed-sdk
├── services
│   └── token.ts  -> Handles fetching auth token from backend

Technology labels

  • React
  • Typescript
  • Web