需要代理身份验证(Forefront TMG 需要授权才能完成请求。对 Web 代理筛选器的访问被拒绝。)
当我尝试向 Twitter 发布消息时,出现上述错误。如何消除该错误?
堆栈跟踪如下:
Exception = {“远程服务器返回错误:(407) 需要代理身份验证。”} ExceptionStatus = ProtocolError
代码:
private string GetOAuthUrl()
{
IFluentTwitter twitter;
//Override the callback url if one was entered
if (CallbackUrl != null && CallbackUrl.Trim().Length > 0)
{
twitter = FluentTwitter.CreateRequest().Configuration.UseHttps().Authentication.GetRequestToken(ConsumerKey, ConsumerSecret, CallbackUrl);
}
else
{
twitter = FluentTwitter.CreateRequest().Configuration.UseHttps().Authentication.GetRequestToken(ConsumerKey, ConsumerSecret);
}
var response = twitter.Request();
UnauthorizedToken UnauthorizedToken = response.AsToken();
string AuthorizationUrl = FluentTwitter.CreateRequest().Authentication.GetAuthorizationUrl(UnauthorizedToken.Token);
return AuthorizationUrl;
}
When I was trying to post messages to Twitter, the above error coming. How to get rid of that error?
The stacktrace is the following:
Exception = {"The remote server returned an error: (407) Proxy Authentication Required."} ExceptionStatus = ProtocolError
Code:
private string GetOAuthUrl()
{
IFluentTwitter twitter;
//Override the callback url if one was entered
if (CallbackUrl != null && CallbackUrl.Trim().Length > 0)
{
twitter = FluentTwitter.CreateRequest().Configuration.UseHttps().Authentication.GetRequestToken(ConsumerKey, ConsumerSecret, CallbackUrl);
}
else
{
twitter = FluentTwitter.CreateRequest().Configuration.UseHttps().Authentication.GetRequestToken(ConsumerKey, ConsumerSecret);
}
var response = twitter.Request();
UnauthorizedToken UnauthorizedToken = response.AsToken();
string AuthorizationUrl = FluentTwitter.CreateRequest().Authentication.GetAuthorizationUrl(UnauthorizedToken.Token);
return AuthorizationUrl;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 fluid twitter 在幕后使用 WebRequests,那么您需要使用如下代码指定代理的凭据:
这将告诉所有 Web 请求使用运行应用程序的用户的凭据来通过代理进行身份验证。
要实现此功能,您需要将应用程序配置为在已被授予代理服务器访问权限的服务帐户下运行。然后,您可以绑定此服务帐户,使其具有尽可能少的权限来运行该服务。
如果您的应用程序需要在无权使用代理服务器的帐户下运行,您可以明确指定凭据,如下所示:
这样做的缺点是您必须将这些凭据存储在某处,并且它们可能会被如果攻击者设法破坏您的应用程序,则会被攻击者捕获。在某些环境中,从安全角度来看这是不可接受的。
If fluent twitter is using WebRequests under the covers, then you need to specify credentials for the proxy using code like this:
This will tell all web requests to use the credentials of the user running the application to authenticate with the proxy.
To make this work, you will need to configure the application to run under a service account which has been granted access to the proxy server. You can then tie down this service account so that it has as few permissions as possible to run the service.
If your application needs to run under an account which doesn't have rights to use the proxy server, you can specify the credentials explicitly as follows:
The down side to this is that you have to store those credentials somewhere, and that they could be captured by an attacker if they managed to compromise your application. In some environments, this is not acceptable from a security standpoint.