Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook SDK Proxy setting C#

I use Facebook SDK .net but I use proxy with authentication to connect to the internet I get the error (407) (407) proxy authentication required how I can set the authentication on Facebook SDK

like image 458
Ahmad Darwish Avatar asked Sep 03 '12 16:09

Ahmad Darwish


1 Answers

There is a static method in FacebookClient which allows you to set it globally.

[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetDefaultHttpWebRequestFactory(Func<Uri, HttpWebRequestWrapper> httpWebRequestFactory)

You might not see it in the intellisense as it is hidden by default.

If you want it per instance you can use the property.

[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Func<Uri, HttpWebRequestWrapper> HttpWebRequestFactory { get; set; }

Here is an example.

FacebookClient.SetDefaultHttpWebRequestFactory(uri => {
    var request = new HttpWebRequestWrapper((HttpWebRequest)WebRequest.Create(uri));
    request.Proxy = ......; // normal .net IWebProxy
    return request;
});
like image 125
prabir Avatar answered Jan 01 '23 17:01

prabir