Ethora Community

Community › Developers (platform specific questions) › Backend, API, Admin Dashboard

Integrating Ethora chat with your existing (legacy) backend. Endpoint requests examples.

Archived from the Ethora community forum. First posted on 10 October 2024; product details may have changed since. For current setup see Get Ethora and GitHub.

 

This video (narrated in Ukrainian by Borys our backend architect engineer) demonstrates integrating Ethora chat with your existing backend.

Endpoint request examples are shown.

Javascript code sample:

const jwt = require("jsonwebtoken")

// example of secret
const secret = 'YOUR_APP_SECRET'
const appId = 'YOUR_APP_ID'

const craeteServerToken = function() {
    return jwt.sign({data: {appId, type: 'server'}}, secret, {
            // expiresIn: 60000,
            algorithm: 'HS256'
    })
}

function createClientToken(userId) {
    return jwt.sign(
        // jwt payload should include current userId & appId
        {data: {type: 'client', userId: userId, appId: appId}},
        // only backend should know secret
        secret,
        // token options 
        {
            expiresIn: 480,
            algorithm: 'HS256'
        })
}

console.log("server token ", craeteServerToken())
console.log("client token ", createClientToken("mock4"))

 

Also attached below is a Postman file demonstrating server token and client token generation.

 

dappros-deepx.postman_collection.jsonUnavailable

Have a question about this? Ask the Ethora team.