Skip to main content

Server-Side Token Generation

To securely authenticate users with the ContactsManager SDK, you need to generate JWT tokens on your server. This guide explains how to create a secure token generation endpoint.

Authentication Flow

  1. Your app requests a token from your server
  2. Your server generates a signed JWT token using your API secret
  3. The server returns the token to your app
  4. Your app initializes the ContactsManager SDK with the token
This approach keeps your API secret secure by never exposing it in client code.

Token Structure

The JWT token contains the following claims:

Implementation Examples

Install the contactsmanager package for easy token generation.

Environment Variables

For all implementations, set these environment variables on your server:

Security Considerations

  1. Keep Your API Secret Secure: Never expose your API secret in client-side code
  2. Set a Reasonable Expiration Time: Balance security and user experience
  3. Use HTTPS: Always use HTTPS for all API endpoints
  4. Validate User ID: Ensure the user ID is valid before generating a token
  5. Implement Rate Limiting: Protect your token endpoint from abuse

Using the Token in your App

Once you have the token from your server, you can use it to initialize the ContactsManager SDK: