Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions modules/ROOT/pages/trusted-auth-sdk.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Cookie-based authentication, specified using `AuthType.TrustedAuthToken`, uses t

For the request to be *secure*, the user in the browser cannot modify the request or make their own valid request to the *token request service* in a way that requests a token for any other user.

The `autoLogin: true` property in the `init()` function causes the Visual Embed SDK to request a new token before the token or the session expires, so that a user never sees the ThoughtSpot embed component in a signed-out state.

== Define token request service
There are two options in the `init()` function to define the request to the *token request service*: `authEndpoint` or `getAuthToken`.

Expand All @@ -40,8 +42,8 @@ The callback function must return a *Promise* that resolves with the *login toke
----
init({
thoughtSpotHost: "<%=tshost%>",
authType: AuthType.TrustedAuthToken,
username: "UserA",
authType: AuthType.TrustedAuthTokenCookieless,
autoLogin: true,
getAuthToken: () => {
// fetch() returns a Promise naturally. Assumes a JSON response from the token request service with a 'token' property
return fetch('https://my-backend.app/ts-token')
Expand All @@ -57,8 +59,7 @@ You can even use the callback function to reference a hard-coded login token, in
----
init({
thoughtSpotHost: "<%=tshost%>",
authType: AuthType.TrustedAuthToken,
username: "<username>",
authType: AuthType.TrustedAuthTokenCookieless,
getAuthToken: () => {
let tsToken = '{long-lived-token}';
return Promise.resolve(tsToken);
Expand Down Expand Up @@ -105,7 +106,8 @@ let tsToken; // global scope to store token for other REST API requests
init({
thoughtSpotHost: tsURL,
authType: AuthType.TrustedAuthTokenCookieless,
getAuthToken: getAuthToken
getAuthToken: getAuthToken,
autoLogin: true
});

function async getAuthToken {
Expand Down Expand Up @@ -146,8 +148,8 @@ function async getAuthToken {
init({
thoughtSpotHost: "<ThoughtSpot-Host-URL>",
authType: AuthType.TrustedAuthToken,
username: "<username>",
authEndpoint: "https://authenticator-server:<port>/endpoint",
autoLogin: true
});
----

Expand All @@ -156,7 +158,7 @@ init({
init({
thoughtSpotHost: "<ThoughtSpot-Host-URL>",
authType: AuthType.TrustedAuthToken,
username: "<username>",
autoLogin: true,
getAuthToken: () => {
return fetch('https://my-backend.app/ts-token')
.then((response) => response.json())
Expand All @@ -172,6 +174,7 @@ init({
thoughtSpotHost: "<ThoughtSpot-Host-URL>",
authType: AuthType.TrustedAuthTokenCookieless,
authEndpoint: "https://authenticator-server:<port>/endpoint",
autoLogin: true
});
----

Expand All @@ -181,6 +184,7 @@ init({
init({
thoughtSpotHost: "<ThoughtSpot-Host-URL>",
authType: AuthType.TrustedAuthTokenCookieless,
autoLogin: true,
getAuthToken: () => {
return fetch('https://my-backend.app/ts-token')
.then((response) => response.json())
Expand Down
Loading