JWT Tokens
Generate JWT Tokens for additional security
Overview
JWT Tokens
is an optional feature to add additional authentication security to our client.identify()
method to prevent user impersonation.
Enable JWT Tokens in your console
Go to https://console.velt.dev and enable the toggle for Require JWT Token
. The toggle is listed at the very bottom of the page.
Create a server endpoint for generating and sending JWT Tokens to the client
Create a server endpoint that will be used to generate and send a JWT Token
to the client.
Example server endpoint code:
Generate a JWT Token using Velt's REST API
In your server endpoint, call our https://api.velt.dev/v1/auth/token/get
endpoint to generate a JWT Token
.
Example server code:
Request Body:
To get your Auth Token that is required for your request body, read here.
Field | Required | Description |
---|---|---|
apiKey | Yes | Velt API Key |
authToken | Yes | Auth Token from the Velt console |
userId | Yes | Unique user id of the user |
userProperties.isAdmin | No | Set to true if you want to set user as admin . This is the only way to set a user as an admin User. Please do not set this property in the identify call as this will unset the isAdmin property. |
userProperties.organizationId | No | If organizationId is provided, it will be validated with the organizationId used in the identify call. Recommended if you are setting organizationId. |
userProperties.email | No | If email is provided, it will be validated with the email used in the identify call. Recommended if you are setting email. |
Success Response:
Failure Response:
Call your server endpoint from your client to pass your JWT Token to your client
Call your server endpoint from your client to pass your JWT Token
to your client.
Pass the JWT Token to client.identify()
Once the JWT Token is generated, you can pass it into the client.identify()
method. The client.identify()
method has an optional second parameter that takes in a configuration object that includes the JWT Token
as a field.
Your All Done!
You are all done! Now you have added an additional level of security with JWT Tokens
.
Was this page helpful?