Token generator examples
Use these examples to generate a personalization token for web authentication. Each example builds the payload described in JWT payload structure and signs it with your widget secret key.
Examples by language [#examples-by-language]
Each example uses the sample values from the token examples, with the following exceptions:
jti: Each example generates a new value for every token. Live Chat rejects a token whosejtiwas already used for the widget.sid: Each example takes the ID of the current user session from your system. Each user session needs its ownsid.
Generate and sign the token on your server. Never put the secret key in your website or app code.
The following tabs contain a JWT generator example in Node.js, Java, Kotlin, Swift, and PHP:
Decode your secret key from Base64 before you use it for the signature.
Authenticate web users
Review token requirements and the JWT payload structure.
Authenticate mobile users
Use the personalization token for additional security in mobile apps.
JavaScript SDK in Live Chat
Submit the generated token to the web widget with the Auth command.
Was this page helpful?