Skip to content
This repository has been archived by the owner on Feb 14, 2025. It is now read-only.

Commit

Permalink
code syntax fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShashiSubramanya authored Feb 7, 2024
1 parent 2ec362d commit 81846d9
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions modules/ROOT/pages/trusted-auth-sdk.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,31 @@ The callback function must return a *Promise* that resolves with the *login toke
[source,JavaScript]
----
init({
thoughtSpotHost: <ThoughtSpot-Host-URL>
authType: AuthType.TrustedAuthToken,
username: "<username>",
getAuthToken: () => {
// fetch() returns a Promise naturally. Assumes a JSON response from token request service with a 'token' property
return fetch('https://my-backend.app/ts-token')
.then((response) => response.json())
.then((data) => data.token);
});
thoughtSpotHost: "<%=tshost%>",
authType: AuthType.TrustedAuthToken,
username: "UserA",
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')
.then((response) => response.json())
.then((data) => data.token);
}
});
----

You can even use the callback function to reference a hard-coded login token, in a testing or other appropriate situation:

[source,JavaScript]
----
init({
thoughtSpotHost: <ThoughtSpot-Host-URL>
authType: AuthType.TrustedAuthToken,
username: "<username>",
getAuthToken: () => {
let tsToken = '{long-lived-token}';
return tsToken;
});
thoughtSpotHost: "<%=tshost%>",
authType: AuthType.TrustedAuthToken,
username: "<username>",
getAuthToken: () => {
let tsToken = '{long-lived-token}';
return tsToken;
}
});
----

See the examples in the following section for more variations on the `getAuthToken` callback function.
Expand Down Expand Up @@ -175,11 +178,12 @@ init({
[source,JavaScript]
----
init({
thoughtSpotHost: <ThoughtSpot-Host-URL>
thoughtSpotHost: "<ThoughtSpot-Host-URL>",
authType: AuthType.TrustedAuthTokenCookieless,
getAuthToken: () => {
return fetch('https://my-backend.app/ts-token')
.then((response) => response.json())
.then((data) => data.token);
}
});
----

0 comments on commit 81846d9

Please sign in to comment.