【发布时间】:2020-11-05 12:11:24
【问题描述】:
我已经下载了 azure 通讯聊天服务,并且可以按照视频中所示的那样工作 https://www.youtube.com/watch?v=2pyKhoIZhJo.
但他们是问题..我如何克服令牌过期..它继续过期的treadID,我无法进一步聊天..
我已经提到了 RefreshToken,虽然它并不令人耳目一新。以下是我所做更改的代码,
var userCredential = new CommunicationUserCredential
(
initialToken: moderator.token,
refreshProactively: true,
tokenRefresher: cancellationToken => fetchNewTokenForCurrentUser(moderator.identity).GetAwaiter().GetResult(),
asyncTokenRefresher: cancellationToken => fetchNewTokenForCurrentUserasync(moderator.identity)
);
fetchNewTokenForCurrentUser 方法如下
private async Task<string> fetchNewTokenForCurrentUser( string identity)
{
CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClient(resourceConnectionString);
CommunicationUser user = new CommunicationUser(identity);
Azure.Response<CommunicationUserToken> tokenResponse = await communicationIdentityClient.IssueTokenAsync
(
user,
scopes: new[] { CommunicationTokenScope.Chat }
);
string token = tokenResponse.Value.Token;
return token;
}
但是这段代码不起作用.. 希望有人能帮助我..提前谢谢
【问题讨论】:
标签: azure chat refresh-token azure-communication-services