Authorization

Introduction

users have to be authorized to use cyxth chat features. this requires that you have a backend server that can be used to generate secure digital tokens that will be used to authenticate users.

install the cyxth backend nodejs sdk or use the cyxth REST api to generate tokens.

using nodejs sdk

cyxth mantains a powerful nodejs backend sdk that can be used to work with cyxth backend, including generating tokens among other functionalities.

once a token has been generated a user must use it to start a cyxth session with 4 minutes , this duration can be altered in the CreateTokenOptions, you can also set the duration where the token is valid.

import Cyxth from '@cyxth/node';

const APP_ID = "cyxth_app_id";
const APP_SECRET = "cyxth_app_secret";

const cyxth = new Cyxth(APP_ID, APP_SECRET);

let test_user = {
    id: "user_id",
    name: "user_name",
    avatar: "user_avatar_url",
}

let token = cyxth.createToken(user)
// use this token to connect a user to cyxth in your frontend

Token revocation

When a new app secret is used all old tokens are revoked and users using them are forced to reauthenticate.

NOTE you can only have one app secret at a time.