Skip to content

Commit

Permalink
PR
Browse files Browse the repository at this point in the history
  • Loading branch information
pballai committed Dec 13, 2024
1 parent 6cca849 commit e4012ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Binary file modified site/sigmaguides/src/embedding_16_JWT/assets/accounttypes22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 11 additions & 4 deletions site/sigmaguides/src/embedding_16_JWT/embedding_16_JWT.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ Search for the `Sales_People` team, select it and provision `Can view` permissio
For those users who have used Sigma embedding before, this step is a little different. We used to use Sigma's UI to create an `Embed Path`.

**This is no longer required when using JWT.**
=======

For those users who have used Sigma embedding before, this step is a little different. We used to use Sigma's UI to create a `Workbook URL` > `Embed Path`. **This is no longer required when using JWT.**

With JWT embedding, we simply use the `Published` url, taken directly from the browser.
Expand Down Expand Up @@ -455,25 +455,32 @@ async function generateSignedUrl() {
const time = Math.floor(Date.now() / 1000); // Current Unix timestamp
const expirationTime = time + Math.min(parseInt(process.env.SESSION_LENGTH) || 3600, 2592000);
// Convert TEAM into an array if it is a single value
const teamsArray = process.env.TEAM ? [process.env.TEAM] : [];
const token = jwt.sign({
sub: process.env.EMAIL,
iss: process.env.CLIENT_ID,
jti: uuid(),
iat: time,
exp: expirationTime,
account_type: process.env.ACCOUNT_TYPE,
team: process.env.TEAM,
teams: teamsArray,
}, process.env.SECRET, {
algorithm: 'HS256',
keyid: process.env.CLIENT_ID
});
const signedEmbedUrl = `${process.env.BASE_URL}?:jwt=${token}&:embed=true`;
// Decode the JWT to inspect its content and log it
const decodedToken = jwt.decode(token, { complete: true });
console.log('Decoded JWT:', decodedToken); // Log the decoded JWT for debugging
const signedEmbedUrl = `${process.env.BASE_URL}?:jwt=${encodeURIComponent(token)}&:embed=true`;
// Log important configuration details to ensure they are correctly set
console.log('BASE_URL:', process.env.BASE_URL);
console.log('CLIENT_ID:', process.env.CLIENT_ID); // Verify the client ID
console.log('SESSION_LENGTH:', process.env.SESSION_LENGTH);
console.log('TEAMS:', process.env.TEAM);
console.log('TEAMS:', teamsArray);
console.log('ACCOUNT_TYPE:', process.env.ACCOUNT_TYPE);
console.log('Signed Embed URL:', signedEmbedUrl);
Expand Down

0 comments on commit e4012ad

Please sign in to comment.