首页 > 解决方案 > 在 bot builder v4 中下载 Skype bot 附件

问题描述

我正在尝试使用 Bot Builder v4 下载在 Skype bot 中上传的图像。使用 httpClient 下载图像时,我已检索 JwtSecurityToken 进行授权。但有时我会收到未经授权的错误。

var context = stepContext.Context;
var channelId = context.Activity.ChannelId;

if (channelId.Equals("skype"))
{
    using (var connectorClient = (ConnectorClient)context.TurnState.First(x => x.Key.Equals("Microsoft.Bot.Connector.IConnectorClient")).Value)
    {
        if (connectorClient?.Credentials != null)
        {
           var credentials = (MicrosoftAppCredentials)connectorClient.Credentials;
           var authToken = await new MicrosoftAppCredentials(credentials.MicrosoftAppId, credentials.MicrosoftAppPassword).GetTokenAsync().ConfigureAwait(false);
        }
    }
}

标签: botframeworkskype

解决方案


推荐阅读