[英]Proxy Authentication in .NET - for external API
I'm developing a twitter messaging utility using Twitter API (twitterizer). 我正在使用Twitter API(twitterizer)开发一个Twitter消息传递实用程序。 But since I'm within a corporate proxy, I'm getting the error '407 Proxy Authentication Required'.
但由于我在公司代理中,我收到错误'407 Proxy Authentication Required'。 Is there any way to authenticate the user before calling the API or use the default proxy settings?
在调用API或使用默认代理设置之前,有没有办法验证用户?
PS Internally the API is using HttpWebRequest. PS内部API使用HttpWebRequest。
This does not answer your question. 这不能回答你的问题。 But the error you are getting is clearly a Proxy authentication error.
但是你得到的错误显然是代理身份验证错误。
You might want to either disable or enable the proxy. 您可能想要禁用或启用代理。
To disable the proxy, in the App.config file add the following configuration 要禁用代理,请在App.config文件中添加以下配置
<system.net>
<defaultProxy enabled="false" useDefaultCredentials="false">
<proxy/>
<bypasslist/>
<module/>
</defaultProxy>
</system.net>
To enable the proxy and to use the default proxy settings(specified in IE) add this configuration in your App.config 要启用代理并使用默认代理设置(在IE中指定),请在App.config中添加此配置
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true">
<proxy/>
<bypasslist/>
<module/>
</defaultProxy>
</system.net>
One of the possible programmatic solutions is to create following proxy: 可能的编程解决方案之一是创建以下代理:
IWebProxy proxy=HttpWebRequest.GetSystemWebProxy();
proxy.Credentials = CredentialCache.DefaultCredentials;
and then assign this to any object that make the network call and accept a proxy,eg: 然后将其分配给任何进行网络调用并接受代理的对象,例如:
WebClient client = new WebClient(); WebClient客户端=新WebClient();
client.proxy= proxy; client.proxy = proxy;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.