Jump to content
Ethora's Community
  • 0

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


TarasFilatov

Question

 

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 = '9ddbf686a76eab7fb35e2f447e66cc0b'
const appId = '6706332db1b1a4e984d3c7bc'

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.json

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...