Agora 代币生成与云功能

问题描述 投票:0回答:1

我正在尝试生成用于视频通话的 Agora 令牌。我已经为此部署了一个云函数,但它给了我以下错误“我收到的错误是“第一个参数必须是字符串类型或 Buffer、ArrayBuffer、Array 或类似数组的对象的实例。”

const admin = require('firebase-admin');
const functions = require('firebase-functions');
const Agora = require("agora-access-token");
admin.initializeApp();

exports.tokenGeneration = functions.https.onRequest((request, response) => {
  const appID = "appId";
  const appCertificate = "appCertificate";
  const uid = request.body.role == 0 ? 0 : 1;
  const role = request.body.role == 0 ? Agora.RtcRole.PUBLISHER : Agora.RtcRole.SUBSCRIBER;
  const channel = request.body.channelName;
  const expirationTimestamp = parseInt(request.body.expireTimestamp);

  const token = Agora.RtcTokenBuilder.buildTokenWithUid(appID, appCertificate, channel, uid, role, expirationTimestamp);
  response.send({ "token" : token });
});

这是我的有效负载:

{ '频道名称': "amankachannel", ‘uid’:0, ‘角色’:1, '过期时间戳': "3456783476547" }

javascript firebase google-cloud-functions token agora.io
1个回答
0
投票

第一个参数 id agora AppID。检查您的AppID是否有效

© www.soinside.com 2019 - 2024. All rights reserved.