我正在将 c# 与 mvc 一起使用。
我使用此代码生成令牌并成功生成。但是在使用.join()加入频道时生成令牌后,它会返回 DYNAMIC_KEY_EXPIRED。我使用“AgoraRTCSDK-3.1.0.js”
我使用https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/csharp生成动态令牌
如果有人对 Agora.io 有经验,请帮助我。
示例代码是..
AccessToken token = new AccessToken(apiKey, appCertificate, channelName, "0");
token.addPrivilege(Privileges.kJoinChannel, _expiredTs);
token.addPrivilege(Privileges.kPublishAudioStream, _expiredTs);
token.addPrivilege(Privileges.kPublishVideoStream, _expiredTs);
string strToken = token.build();
public string build()
{
this._messageRawContent = Utils.pack(this.message);
this._signature = generateSignature(_appCertificate
, _appId
, _channelName
, _uid
, _messageRawContent);
this._crcChannelName = Crc32CAlgorithm.Compute(this._channelName.GetByteArray());
this._crcUid = Crc32CAlgorithm.Compute(this._uid.GetByteArray());
PackContent packContent = new PackContent(_signature, _crcChannelName, _crcUid, this._messageRawContent);
byte[] content = Utils.pack(packContent);
return getVersion() + this._appId + Utils.base64Encode(content);
}