Skip to main content
This guide covers how to generate secure, time-limited tokens for embedding dashboards in your application.
This page is specifically about the multi-tenant iframe token flow. If you are embedding Papermap through @papermap/papermap, see React Components for the component integration flow and how it uses workspaceId, dashboardId, and backend token generation.

Overview

Iframe tokens allow you to securely embed Papermap dashboards in your application. Each token:
  • Is signed with HMAC-SHA256 for security
  • Has a configurable expiration time
  • Is specific to a tenant and dashboard
  • Can only be used for the specified dashboard

Token Structure

The token contains:
  • api_key_id: Your API key identifier
  • workspace_id: Your workspace ID
  • tenant_id: The tenant identifier
  • dashboard_id: The specific dashboard ID
  • valid_until: Unix timestamp when token expires
  • signature: HMAC signature for verification

Generating Iframe Tokens

This token generation is different from the one in the Basic Embedding section. The token generation in this section is for multi-tenant iframe embedding.
The tenant-aware dashboardId and backend provisioning model described here can still be relevant when your application uses React components, but this page documents the iframe-specific token flow.

Using the Token in Frontend

Once you have the token, embed the dashboard using an iframe:

React Example

Workflow Diagram

Token Refresh

Since tokens expire, implement a refresh mechanism:

Security Considerations

Always verify tenant ownership before generating tokensNever generate a token without verifying that the requesting user has access to the tenant’s dashboard.

Tenant Access Verification

Token Expiration

  • Advisable: 1 hour (3600 seconds)
  • Configurable based on your security requirements
  • Shorter expiration = more secure, but requires more frequent refreshes
  • Longer expiration = better UX, but higher security risk

Best Practices

  1. Generate tokens on-demand: Don’t pre-generate and store tokens
  2. Use HTTPS: Always serve your application over HTTPS
  3. Implement token refresh: Refresh tokens before they expire
  4. Log token generation: Monitor for unusual access patterns
  5. Rate limit: Prevent abuse by rate limiting token generation

Next Steps

API Endpoints

Set up REST API endpoints for dashboard operations

Security Best Practices

Learn about security considerations for production