Backend Token Authentication
Backend token authentication lets you secure the Notification Center widget using your own auth system. Your backend generates an HMAC token with the Node.js SDK, and the frontend passes it to the widget to prove the user’s identity.This is the recommended approach for production applications. It ensures that only your backend can authorize widget connections.
How it works
Backend generates token
Your backend calls
client.generateHashedToken(userId) using the Node.js SDK.Token sent to frontend
Your backend returns the token to the frontend (e.g. in the login response or via a dedicated endpoint).
Backend setup
Install the Node.js SDK and generate a token for each authenticated user:generateHashedToken() produces a SHA-256 HMAC hash derived from the user ID and your Auth Secret Key. It is deterministic — the same user ID always produces the same token.
Frontend setup
Pass the token and user identity to the widget:- React
- Angular
- Vanilla JS
Required fields
| Field | Type | Description |
|---|---|---|
authType | "backendToken" | Must be set to "backendToken". |
token | string | The HMAC token from generateHashedToken(). |
userId | string | The user’s unique identifier (must match the ID used to generate the token). |
userEmail | string | The user’s email address. |
Security considerations
The token is tied to a specific user ID. If someone intercepts a token, they can only access notifications for that user — they cannot impersonate another user without a valid token for that ID.Next steps
Node.js SDK
Full reference for
generateHashedToken() and other methods.Firebase authentication
Alternative: authenticate with Firebase ID tokens.