Proxy Authentication in .NET - for external API
Asked Answered
B

2

8

I'm developing a twitter messaging utility using Twitter API (twitterizer). But since I'm within a corporate proxy, I'm getting the error '407 Proxy Authentication Required'. Is there any way to authenticate the user before calling the API or use the default proxy settings?

P.S Internally the API is using HttpWebRequest.

Beatrix answered 27/5, 2009 at 6:46 Comment(0)
D
10

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

<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

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy/>
    <bypasslist/>
    <module/>
  </defaultProxy>
</system.net>
Dismay answered 27/5, 2009 at 6:57 Comment(1)
Thanks a lot! I'm able to use default proxy setting using useDefaultCredentials="true" I didn't know this...Thanks!Beatrix
S
3

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,e.g:

WebClient client = new WebClient();
client.proxy= proxy;

Souvaine answered 21/11, 2012 at 12:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.