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
- Your app requests a token from your server
- Your server generates a signed JWT token using your API secret
- The server returns the token to your app
- Your app initializes the ContactsManager SDK with the token
Token Structure
The JWT token contains the following claims:Claim | Description |
---|---|
org_id | Your organization ID |
api_key | Your ContactsManager API key |
user_id | The unique identifier for the user |
jti | A unique token identifier (UUID) |
iat | Token issued at timestamp |
exp | Token expiration timestamp |
Implementation Examples
Install the
contactsmanager
package for easy token generation.Environment Variables
For all implementations, set these environment variables on your server:Variable | Description |
---|---|
CM_API_KEY | Your ContactsManager API key |
CM_API_SECRET | Your ContactsManager API secret |
CM_ORGANIZATION_ID | Your organization ID |
Security Considerations
- Keep Your API Secret Secure: Never expose your API secret in client-side code
- Set a Reasonable Expiration Time: Balance security and user experience
- Use HTTPS: Always use HTTPS for all API endpoints
- Validate User ID: Ensure the user ID is valid before generating a token
- Implement Rate Limiting: Protect your token endpoint from abuse