The remote server returned an error: (401) Unauthorized.

606 views
Skip to first unread message

Matthew Beck

unread,
Dec 19, 2010, 10:06:14 AM12/19/10
to google-analytics...@googlegroups.com
I am using Google Data API SDK 1.6.0.0 for .NET C#.

When trying to get a response from an http web request (see request uri string below) when executing the source code on my home machine, everything works great.  I get data back from Google Analytics API as expected.

When I move this code to my work machine (yes, we use a proxy server) I get "The remote server returned an error: (401) Unauthorized.".  I pass in my credentials for the proxy server as I do for other API calls (like twitter, adwords, etc...) See my code below for proxy credentials.  

I did step through the code and it is getting my authentication token using my credentials (gmail user name and password) as I would expect.  So it does get an authentication token just fine!!!!  

I'm not sure if I still have issues with our proxy server or if Google has our IP address blocked for some reason?  PLEASE HELP!!!

URI String

Proxy Authentication
GDataRequestFactory requestFactory = (GDataRequestFactory)asv.RequestFactory;
IWebProxy iProxy = WebRequest.DefaultWebProxy;
WebProxy webProxy = new WebProxy(iProxy.GetProxy(query.Uri));
webProxy .Credentials = CredentialCache.DefaultCredentials;
webProxy .UseDefaultCredentials = true;
requestFactory.Proxy = webProxy ;

mike@analyticsedge

unread,
Jan 11, 2011, 6:41:03 PM1/11/11
to google-analytics-api - GA Data Export API
since you've been waiting a while...not sure if this is still needed,
but here's what we've used:

IWebProxy proxy = WebRequest.GetSystemWebProxy();
proxy.Credentials = CredentialCache.DefaultCredentials;
webRequest.Proxy = proxy;


On Dec 19 2010, 10:06 am, Matthew Beck <matthewjohnb...@gmail.com>
wrote:
> I am using Google Data API SDK 1.6.0.0 for .NET C#.
>
> When trying to get a response from an http web request (see request uri
> string below) when executing the source code on my home machine, everything
> works great.  I get data back from Google Analytics API as expected.
>
> When I move this code to my work machine (yes, we use a proxy server) I get
> "The remote server returned an error: (401) Unauthorized.".  I pass in my
> credentials for the proxy server as I do for other API calls (like twitter,
> adwords, etc...) See my code below for proxy credentials.  
>
> I did step through the code and it is getting my authentication token using
> my credentials (gmail user name and password) as I would expect.  So it does
> get an authentication token just fine!!!!  
>
> I'm not sure if I still have issues with our proxy server or if Google has
> our IP address blocked for some reason?  PLEASE HELP!!!
>
> *URI String*https://www.google.com/analytics/feeds/data?dimensions=ga%3Adate&end-...
>
> *Proxy Authentication*
Reply all
Reply to author
Forward
0 new messages