### Copy Environment File for Local Development
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
Copy the example environment file for local development and edit it with your Metabase instance URL, JWT secrets, and dashboard ID.
```bash
cp .env.example .env
# Edit .env with your Metabase instance URL, JWT secrets, and dashboard ID
```
--------------------------------
### Run E2E Tests
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
To run the end-to-end tests, first start the Docker containers, then navigate to the e2e directory, install dependencies, and run the Cypress tests.
```bash
# Start Docker containers
npm run docker:up
# Run Cypress tests
cd e2e
npm install
npm run cypress:run
```
--------------------------------
### Copy Environment File for Docker
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
Copy the example environment file for Docker and edit it to add your Metabase premium embedding token.
```bash
cp .env.docker.example .env.docker
# Edit .env.docker and add your MB_PREMIUM_EMBEDDING_TOKEN
```
--------------------------------
### Docker Environment Variables for Local Development
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/DEV.md
Define these environment variables in your `.env.docker` file to enable local Docker testing with specific development settings.
```env
MB_RUN_MODE="dev"
METASTORE_DEV_SERVER_URL="https://token-check.staging.metabase.com"
```
--------------------------------
### Use SSO Authentication in Client
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
The client-side uses SSO authentication by providing the dashboard ID and configuring Metabase with the instance URL and the JWT provider URI.
```html
```
--------------------------------
### Use Signed JWT in Client for Guest Embed
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
The client-side uses the signed token provided by the server within the `` component. It also configures Metabase with guest embedding settings.
```html
```
--------------------------------
### Generate Signed JWT for Guest Embed
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
The server generates a signed JWT token for guest embeds. This token includes the resource ID, parameters, and an expiration timestamp.
```javascript
const payload = {
resource: { dashboard: 1 },
params: {},
exp: Math.round(Date.now() / 1000) + 10 * 60,
};
const token = jwt.sign(payload, MB_EMBEDDING_SECRET_KEY);
```
--------------------------------
### Generate User JWT for SSO Embed
Source: https://github.com/metabase/metabase-nodejs-modular-embedding-sample/blob/main/README.md
The server returns a JWT at the /auth/sso endpoint for SSO embeds. This token contains user information and is signed with a shared secret.
```javascript
const ssoPayload = {
email: "rene@example.com",
first_name: "Rene",
last_name: "Descartes",
groups: ["Customer"],
exp: Math.round(Date.now() / 1000) + 10 * 60,
};
const ssoToken = jwt.sign(ssoPayload, MB_JWT_SHARED_SECRET);
res.json({ jwt: ssoToken });
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.