diff --git a/modules/ROOT/pages/trusted-auth-sdk.adoc b/modules/ROOT/pages/trusted-auth-sdk.adoc index eb3b02805..331dc851c 100644 --- a/modules/ROOT/pages/trusted-auth-sdk.adoc +++ b/modules/ROOT/pages/trusted-auth-sdk.adoc @@ -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`. @@ -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') @@ -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: "", + authType: AuthType.TrustedAuthTokenCookieless, getAuthToken: () => { let tsToken = '{long-lived-token}'; return Promise.resolve(tsToken); @@ -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 { @@ -146,8 +148,8 @@ function async getAuthToken { init({ thoughtSpotHost: "", authType: AuthType.TrustedAuthToken, - username: "", authEndpoint: "https://authenticator-server:/endpoint", + autoLogin: true }); ---- @@ -156,7 +158,7 @@ init({ init({ thoughtSpotHost: "", authType: AuthType.TrustedAuthToken, - username: "", + autoLogin: true, getAuthToken: () => { return fetch('https://my-backend.app/ts-token') .then((response) => response.json()) @@ -172,6 +174,7 @@ init({ thoughtSpotHost: "", authType: AuthType.TrustedAuthTokenCookieless, authEndpoint: "https://authenticator-server:/endpoint", + autoLogin: true }); ---- @@ -181,6 +184,7 @@ init({ init({ thoughtSpotHost: "", authType: AuthType.TrustedAuthTokenCookieless, + autoLogin: true, getAuthToken: () => { return fetch('https://my-backend.app/ts-token') .then((response) => response.json())