如何在Agora聊天应用的临时令牌在24小时后过期时生成新的令牌?

huangapple go评论97阅读模式
英文:

How do i generate the agora Chat App Temp Token when it expires after 24Hours

问题

文档未提及如何重新生成令牌。我尝试构建一个简单的令牌服务器,但生成的令牌无法工作。令牌服务器链接:https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/nodejs

如何在Agora聊天应用的临时令牌在24小时后过期时生成新的令牌?

英文:

The documentation does not mention how to regenerate it. I have tried building a simple token server but the tokens it generates are not working.
Link to token server: https://github.com/AgoraIO/Tools/tree/master/DynamicKey/AgoraDynamicKey/nodejs

如何在Agora聊天应用的临时令牌在24小时后过期时生成新的令牌?

答案1

得分: 2

以下是您要翻译的内容:

Node.js示例代码

用于构建AgoraChat应用程序令牌和用户令牌的Node.js示例代码如下:

const ChatTokenBuilder = require("../src/ChatTokenBuilder").ChatTokenBuilder;
const appId = "970CA35de60c44645bbae8a215061b33";
const appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
const userUuid = "a7180cb0-1d4a-11ed-9210-89ff47c9da5e";
const expirationInSeconds = 600;

const userToken = ChatTokenBuilder.buildUserToken(appId, appCertificate, userUuid, expirationInSeconds);
console.log("Chat User Token: " + userToken + "\n");

const appToken = ChatTokenBuilder.buildAppToken(appId, appCertificate, expirationInSeconds)
console.log("Chat App Token: " + appToken);

示例代码链接:https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/nodejs/sample/ChatTokenBuilderSample.js

类似的帖子在这里:https://stackoverflow.com/a/75694520/21047572

希望对您有所帮助。

英文:

Nodejs Sample Code

Nodejs sample Code to build appToken and userToken for AgoraChat below

const ChatTokenBuilder = require("../src/ChatTokenBuilder").ChatTokenBuilder;
const appId = "970CA35de60c44645bbae8a215061b33";
const appCertificate = "5CFd2fd1755d40ecb72977518be15d3b";
const userUuid = "a7180cb0-1d4a-11ed-9210-89ff47c9da5e";
const expirationInSeconds = 600;

const userToken = ChatTokenBuilder.buildUserToken(appId, appCertificate, userUuid, expirationInSeconds);
console.log("Chat User Token: " + userToken + "\n");

const appToken = ChatTokenBuilder.buildAppToken(appId, appCertificate, expirationInSeconds)
console.log("Chat App Token: " + appToken);

Link to sample code https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/nodejs/sample/ChatTokenBuilderSample.js

Similar post here https://stackoverflow.com/a/75694520/21047572

Hope this helps

huangapple
  • 本文由 发表于 2023年5月25日 13:39:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76329219.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定