Skip to main content
This guide covers secure authentication practices for integrating with Fanfare.

API Key Management

Types of Keys

Publishable Keys

Publishable keys are designed for client-side use:
Capabilities:
  • Initialize SDK
  • Enter experiences
  • Check queue status
  • Consumer authentication
Limitations:
  • Cannot access admin functions
  • Cannot read other users’ data
  • Rate limited more aggressively

Secret Keys

Secret keys provide full API access:
Never expose secret keys in client-side code, mobile apps, or public repositories.

Secure Key Storage

Environment Variables:
Secrets Managers:
  • AWS Secrets Manager
  • Google Secret Manager
  • HashiCorp Vault
  • Vercel Environment Variables

Key Rotation

Rotate keys periodically or after potential exposure:
  1. Generate new key in dashboard
  2. Update your application
  3. Test thoroughly
  4. Revoke old key

Consumer Authentication

Authentication Methods

Fanfare supports multiple consumer authentication methods:

Guest Authentication

For anonymous access with device binding:

OTP Authentication

For verified consumer identity:
OTP Security:
  • Codes expire after 10 minutes
  • Limited retry attempts
  • Rate limited requests
  • Invalid codes logged for monitoring

Session Management

Token Security

JWT Structure

Consumer tokens are JWTs with these claims:

Token Handling

localStorage is vulnerable to XSS attacks. For high-security applications, consider httpOnly cookies.
URLs can be logged, cached, and shared. Use headers for token transmission.
When processing handoff tokens, always validate on your server.

Server-Side Authentication

Validating Consumer Requests

When consumers interact with your backend:

Webhook Authentication

Verify webhook signatures:

Security Checklist

Development

  • Use test keys only in development
  • Never commit keys to version control
  • Add .env to .gitignore
  • Use separate test and production keys

Production

  • Use live keys in production
  • Store keys in secrets manager
  • Enable key rotation policy
  • Monitor for unauthorized access
  • Set up alerts for authentication failures

Code Review

  • No hardcoded credentials
  • Secret keys only in server-side code
  • Token handling follows best practices
  • Webhook signatures verified
  • Error messages don’t leak sensitive info

Common Mistakes

Exposing secret keys

Wrong: Including sk_ keys in client bundles Right: Only use pk_ keys client-side

Not validating handoffs

Wrong: Trusting client-sent handoff tokens Right: Always validate tokens server-side

Ignoring token expiration

Wrong: Assuming tokens are always valid Right: Handle expiration and refresh

Skipping webhook verification

Wrong: Processing webhooks without checking signature Right: Always verify webhook signatures