hoangduit / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Incorrect work through proxy with NTLM auth #370

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Windows (7, XP), .NET 2.0, GData API 1.5.0.0
SQUID (or any other proxy with NTLM auth)

Proxy config and credentials are correct and pre-configured in WebProxy myProxy 
object.

This code throws exception "(407) Proxy Authentication Required."

CalendarQuery query = new CalendarQuery();
query.UseSSL = true;
query.Uri = new 
Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
query.BaseAddress = query.Uri.AbsoluteUri;

((GDataRequestFactory)googleService.RequestFactory).Proxy = myProxy;
CalendarFeed resultFeed = googleService.Query(query);

But if before querying googleService I perform regular HttpWebRequest with the 
same settings, code works well:

HttpWebRequest hwRequest = 
(HttpWebRequest)WebRequest.Create("https://www.google.com/");
hwRequest.Proxy = settings.Proxy.WebProxy;
HttpWebResponse hwResponse = (HttpWebResponse)hwRequest.GetResponse();
//then the same code requesting calendars.
CalendarQuery query = new CalendarQuery();
query.UseSSL = true;
query.Uri = new 
Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
query.BaseAddress = query.Uri.AbsoluteUri;

((GDataRequestFactory)googleService.RequestFactory).Proxy = myProxy;
CalendarFeed resultFeed = googleService.Query(query);

Attached are network logs 

Original issue reported on code.google.com by nre...@gmail.com on 16 Apr 2010 at 11:16

Attachments:

GoogleCodeExporter commented 9 years ago
Addition: correct work reproduced only if System.NET trace is enabled... 
Otherwise 
always got error 407

Original comment by nre...@gmail.com on 16 Apr 2010 at 12:09

GoogleCodeExporter commented 9 years ago
Are you sure your proxy object is correctly configured? Exhibit a:

a) in both logs the .NET runtime tries to use the proxy
b) in both logs it fails initially

Looks to me like the .NET version you are using and your proxy are not working 
well
together. Even in your "good.log" file, the http request you are executing 
yourself
is failing....

Original comment by fman...@gmail.com on 26 Apr 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Request is not failing. After initial request to proxy it returns 407 - proxy 
requires 
authentication. Then auth procedure should be performed (and it is in 
good.log). It's 
standard behavior for any proxy with auth, as described in RFC 3261.

Nevermind, bug is in core of .NET - it doesn't work with squid in NTLM auth 
mode. I 
had to implement workaround for it.

Original comment by nre...@gmail.com on 27 Apr 2010 at 6:42

GoogleCodeExporter commented 9 years ago
I understand. What i meant is that your direct call with the WebRequest class 
is failing the proxy auth as well. So 
it's unlikely to be an issue with the .NET client library. Do you happen to 
know the knowledgebase article about 
that?

Original comment by fman...@gmail.com on 27 Apr 2010 at 7:11

GoogleCodeExporter commented 9 years ago
http://support.microsoft.com/kb/928563 - here is the article where bug is 
described 
as fixed in non-public update. 
http://support.microsoft.com/kb/948609 - here is the article where MS described 
that 
particular update to .NET contains this fix.
http://social.msdn.microsoft.com/Forums/en/ncl/thread/
dd6d3eca-7c0a-4b0e-9d22-2df9f7995dae - here is thread with answer from 
Microsoft "I 
don't know what's up"
http://www.windows-tech.info/13/1e3b50751c81de75.php - this is the same issue.

So, for proxy with NTLM auth (probably squid only) I have to perform google 
auth 
through IE, and then use received token in work with google through http. 

Original comment by nre...@gmail.com on 27 Apr 2010 at 7:30