Authenticate Users
Creating an authentication token for your user
Generating an Authentication Token
To allow your users to authenticate with our web app through the THNDR SDK, you need to generate an authentication token. This token should be created when the user initiates an action to open the THNDR game (e.g., a button click).

Steps to Generate the Authentication Token:
Server-Side Service: The authentication token must be generated server-side to securely handle the API key that we provide. Do not expose the API key on the client-side to avoid security risks.
Calling the Authentication Endpoint: Your server should make a
POST
request to the following endpoint, including the user's metadata:POST https://api-sandbox.clinch.gg/v0/wager/operator/create-token
Request Body:
{ "userId": "<userId>", "displayName": "<userName>", }
userId
: The unique ID of your user.displayName
: The display name of the user.
Request Header:
x-operator-id: your_operator_id x-api-key: your_api_key
Response: Upon successful authentication, the endpoint will return a token in the response:
Response Example:
{ "status": 200, "data": { "token": "eyJhbGciOiJSUzI1NiIsInR5cC..." } }
Using the Token in the
getToken
Callback: Once you receive the token in the server response, return this token in thegetToken
callback of the THNDR SDK. Here's an example:function async getToken() { const response = await post('https://your-server.com/thndr/login'); const data = await response.json(); return data.token; }
Token Expiry
Authentication tokens used during SDK initialization are JWTs that expire after 1 hour. If an expired token is passed when opening the game, it will fail to load. To prevent this, it's recommend to generate a fresh token each time the game initializes.
Alternatively, you can decode the token (e.g., using jwt.io) to inspect the exp
field and only regenerate when it's close to expiration. However, generating a new token on each game load is the simpler and more robust approach.
Last updated