gauravtyagi2777 / google-gdata

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

-> System.Net.WebException : The remote server returned an error: (403) Forbidden. #613

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I have some custom code for checking some results from GA. It was working fine 
but now getting 

RB.Digital.DigitalReporting.Selenium.Tests.calgonbeYearToDate 
(TestFixtureSetUp):
SetUp : Google.GData.Client.GDataRequestException : Execution of request 
failed: 
https://www.google.com/analytics/feeds/data?end-date=2012-07-31&ids=ga:18164091&
metrics=ga:visitors&start-date=2012-07-01
  ----> System.Net.WebException : The remote server returned an error: (403) Forbidden.

Original issue reported on code.google.com by rbwebt...@gmail.com on 9 Aug 2012 at 10:52

GoogleCodeExporter commented 8 years ago
403 is returned when the user is not authorized to perform the action, this 
doesn't look like a bug in the library. Please double check the credentials you 
are using.

Also, please try sending the same request with the OAuth 2.0 Playground 
(https://code.google.com/oauthplayground/) and compare it with the one you are 
sending from your application. You can capture your request using a tool like 
Fiddler.

I think this issue should be closed as working as intended, please add more 
details in case you think the issue is indeed in the client library.

Original comment by ccherub...@google.com on 9 Aug 2012 at 3:55

GoogleCodeExporter commented 8 years ago
I have also come across this issue, starting 4th August. Code which has been 
working for over a year has suddenly started to return:

The remote server returned an error: (403) Forbidden.

oAuth credentials have never changed, nor has the code.

InnerException: The remote server returned an error: (403) Forbidden.

Error Message: Execution of request failed: 
https://www.google.com/analytics/feeds/data?end-date=2012-08-13&ids=ga:53793071&
metrics=ga:bounces,ga:newVisits,ga:pageviews,ga:timeOnPage,ga:timeOnSite,ga:visi
ts,ga:goalStartsAll,ga:goalAbandonsAll,ga:goalCompletionsAll,ga:goalValueAll&sta
rt-date=2012-07-14

Error Source: aGoogleAnalytics

Error Stack Trace: at Google.GData.Client.GDataRequest.Execute() at 
Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter) at 
Google.GData.Client.GDataGAuthRequest.Execute() at 
Google.GData.Client.Service.Query(Uri queryUri, DateTime ifModifiedSince, 
String etag, Int64& contentLength) at Google.GData.Client.Service.Query(Uri 
queryUri, DateTime ifModifiedSince) at 
Google.GData.Client.Service.Query(FeedQuery feedQuery) at 
Google.GData.Analytics.AnalyticsService.Query(DataQuery feedQuery) at 
Code.Loaders.ProfileLoader.CompleteTask(Object state) 

Original comment by google.a...@admeter.co.uk on 13 Aug 2012 at 2:36

GoogleCodeExporter commented 8 years ago
Please add the smallest possible code to reproduce the issue so that I can 
perform some tests.

Original comment by ccherub...@google.com on 13 Aug 2012 at 3:51

GoogleCodeExporter commented 8 years ago
Closing as non reproducible, feel free to reopen if the issue is still valid 
and you can add the steps (code and http log) to reproduce it.

Original comment by ccherub...@google.com on 17 Aug 2012 at 6:32

GoogleCodeExporter commented 8 years ago
Hi, I have the same issue and I can't figure out what the problem is. Over the 
last week it has worked on an off and since yesterday every request returns 
403: forbidden. It has been working fine for over 2 years, has the API been 
recently updated that I need to do something else? 

Any help greatly appreciated.
THanks.

Original comment by noemi.mo...@red-gate.com on 20 Aug 2012 at 6:59

GoogleCodeExporter commented 8 years ago
I'm not aware of any changes to the API, I'd recommend asking in the Google 
Analytics developer forums:

https://developers.google.com/analytics/community/

Original comment by ccherub...@google.com on 20 Aug 2012 at 4:11

GoogleCodeExporter commented 8 years ago
In the end is a minor change. All I had to do is register in the project in the 
Google APIs console and use the API Key on my request and is now working fine 
again. Thanks for replying though.

Original comment by noemi.mo...@red-gate.com on 20 Aug 2012 at 4:20

GoogleCodeExporter commented 8 years ago
I'm using the Google API on my website. It works
fine from my localhost, but on the live server I get the following
error:

System.Net.WebException: The remote server returned an error: (403)
Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at GoogleUrlShortnerApi.Shorten(String url)

I'm using the code found here:
http://www.thecyberwizard.com/index.php/5/google-analytics-api-in-c-part-1/

And from debugging, I see that the error occurs on the
 HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
command.

Does anyone know what could be causing the error (again, the error
happens only on the server. When I run this code locally on my
computer, it runs fine and retrieves a short url). 

I have to turn off billing still I get the following
error:
System.Net.WebException: The remote server returned an error: (403)  

Please help me...

Original comment by braintec...@gmail.com on 28 Aug 2012 at 8:56

GoogleCodeExporter commented 8 years ago
It's working by changing the _autoPostData value to 
"“?accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=analytics&sour
ce=thecyberwizard.comâ"

Original comment by braintec...@gmail.com on 31 Aug 2012 at 6:47

GoogleCodeExporter commented 8 years ago
Following is the code I am using to get analytics data:

//Code Start
AnalyticsService asv = new AnalyticsService("Data Export");
asv.setUserCredentials("MyUsername", "MyPassword");
String baseUrl = "https://www.google.com/analytics/feeds/data";
DataQuery query = new DataQuery(baseUrl);
query.Ids = "MyClientAnalytic ID";
query.Dimensions = "ga:pagePath,ga:date";
query.Metrics = 
"ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits"
;
query.Filters = "ga:medium==referral";
query.Sort = "-ga:pageviews";
query.NumberToRetrieve = 10000;
query.GAStartDate = "2012-01-07";
query.GAEndDate = "2013-01-07";
Uri url = query.Uri;

System.Diagnostics.Debug.WriteLine("URL: " + url.ToString());

// Send our request to the Analytics API and wait for the results to come back.
DataFeed feed = asv.Query(query);
//Code End

The above code was always working until recently I started getting this 
exception :

"System.Net.WebException : The remote server returned an error: (403) Forbidden"

I am going through all the answers above but I m not sure how I can 
incorportate the solution provided by noemi.mo...@red-gate.com which he says(I 
have no idea what he/she meant?):

"All I had to do is register in the project in the Google APIs console and use 
the API Key on my request and is now working fine again"

Also the solution provided by braintec...@gmail.com(I have no idea what he/she 
meant either?):

"It's working by changing the _autoPostData value to 
"“?accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=analytics&sour
ce=thecyberwizard.comâ"

I am getting the results on https://ga-dev-tools.appspot.com/explorer/ and 
https://code.google.com/oauthplayground/ with all the same input values that I 
am sending through the code. Please help me.

Original comment by aa...@webqa.net on 5 Feb 2013 at 4:05

GoogleCodeExporter commented 8 years ago
I am also having the same issues.  Everything was working fine till today now 
I'm receiving a "403 forbidden" error.  I'm using 
https://www.google.com/accounts/ClientLogin to validate my account.

Original comment by jmill....@gmail.com on 9 Feb 2013 at 1:05

GoogleCodeExporter commented 8 years ago
same problem. Badauthentication.

Code worked fine yesterday

Original comment by research...@gmail.com on 18 Apr 2013 at 3:27