在代理后面托管本地聊天机器人。试图找出一种在OAuthPrompt对话框中自定义HttpClient的方法,以便我可以配置代理设置。
AddDialog (new OAuthPrompt (
nameof (OAuthPrompt),
new OAuthPromptSettings {
ConnectionName = _configuration["ConnectionName"],
Text = "Please login",
Title = "Login",
Timeout = 300000, // User has 5 minutes to login
}));
private async Task<DialogTurnResult> IntroStepAsync (WaterfallStepContext stepContext, CancellationToken cancellationToken) {
return await stepContext.BeginDialogAsync (nameof (OAuthPrompt), null, cancellationToken);
}
答案 0 :(得分:0)
不是专门针对OAuth,但您可以通过代理运行整个机器人。
using System;
using System.Net;
namespace ProxyBot
{
public class MyProxy : IWebProxy
{
public MyProxy()
{
//here you can load it from your custom config settings
this.ProxyUri = new Uri("<myProxyUrl:Port>");
}
public Uri ProxyUri { get; set; }
public ICredentials Credentials { get; set; }
public Uri GetProxy(Uri destination)
{
return this.ProxyUri;
}
public bool IsBypassed(Uri host)
{
//you can proxy all requests or implement bypass urls based on config settings
return false;
}
}
}
Startup.cs
services.AddHttpClient<MyProxy>();
您可能需要更新Bot.Builder软件包;我们最近对代理支持做了一些更改。