403-Forbidden when using the API

5,799 views
Skip to first unread message

Eduardo Scoz

unread,
Dec 28, 2011, 10:44:04 PM12/28/11
to google-analytics...@googlegroups.com
Hey guys,

I'm trying to port Quicklytics, my iPhone app (quicklytics.com) to the new v3 API, but I'm getting an error when trying to get data from the Data Export API. 

Everything goes fine with OAuth (authentication, and then getting the real token), but once I call the analytics API to get data, I get the 403 error. I tried passing the auth token via both a header parameter ("Authorization: Bearer __CODE___") and the URL parameter ("&access_token=__CODE__), and I always get the same error:

 {"error":{"errors":[{"message":"Forbidden"}],"code":403,"message":"Forbidden"}}

I would appreciate any help! More info below:

I tried also the Google API Explorer, and I get this error: 

analytics » v3 » data.ga.get executed moments ago time to execute: 109 ms
You do not have permission to execute this method.

I have also tried the Google OAuth 2.0 Playground, and i get the same error (auth code is modified):

GET /analytics/v3/data/ga?ids=ga:259287&dimensions=ga:Hour&metrics=ga:Visits,ga:Pageviews,ga:Bounces&start-date=2011-12-24&end-date=2011-12-26 HTTP/1.1
Host: www.googleapis.com
Authorization: OAuth ya29.AHES6ZTQkuiFsMS____SOMETHINGHERE_____mO_KQqmkTbw-S7j2xbYw
HTTP/1.1 403 Forbidden
status: 403
content-length: 79
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
expires: Thu, 29 Dec 2011 03:30:49 GMT
x-google-cache-control: remote-fetch
server: GSE
via: HTTP/1.1 GWA
cache-control: private, max-age=0
date: Thu, 29 Dec 2011 03:30:49 GMT
x-frame-options: SAMEORIGIN
content-type: application/json; charset=UTF-8
-content-encoding: gzip
{"error":{"errors":[{"message":"Forbidden"}],"code":403,"message":"Forbidden"}}

Eduardo Scoz

unread,
Dec 28, 2011, 11:23:36 PM12/28/11
to google-analytics...@googlegroups.com
By the way, it's worth mentioning that I can successfully download data from the management API and get all the web properties for a user. Making a request with the proper authentication header on this URL works just fine: 

Eduardo Scoz

unread,
Dec 29, 2011, 9:57:35 AM12/29/11
to google-analytics...@googlegroups.com
One more update: I just tried using other APIs (like the tasks API, and the authentication works just fine.  Just changing the URL to point to a different service (and adding the scope) works, with the same header authentication parameter.

This must be some kind of problem on the API side.. help! 

Eduardo Scoz

unread,
Dec 29, 2011, 10:27:41 AM12/29/11
to google-analytics...@googlegroups.com
So it seems like the problem was my fault. I was using the incorrect ID on the Google Analytics profile to pull the data. Oh well. 

Nick

unread,
Dec 29, 2011, 1:02:15 PM12/29/11
to google-analytics-api - GA Data Export API
Thats great you solved it!

-Nick

ryan marshall

unread,
Feb 27, 2012, 8:11:14 PM2/27/12
to google-analytics...@googlegroups.com
can you explain a little more about the ID you were incorrectly using? I'm having the same issue

Prachyut Shrestha

unread,
Sep 5, 2013, 12:11:18 PM9/5/13
to google-analytics...@googlegroups.com
Eduardo, 

I am continually running into (403) Forbidden issue. I am guessing, my issue is similar to what you had, something to do with ID on Google Analytics profile or wrong API or IDs pointing to wrong API. Could you elaborate more?

Thank you,

Eduardo Scoz

unread,
Sep 5, 2013, 12:16:56 PM9/5/13
to google-analytics...@googlegroups.com
It's been a while, but if I remember correctly, I was using the property ID instead of the profile ID when reading the data. Check to make sure you're using both ids correctly.


--
You received this message because you are subscribed to a topic in the Google Groups "Google Analytics Reporting API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-data-export-api/Hl7nH-HW7cE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-analytics-data-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Prachyut Shrestha

unread,
Sep 6, 2013, 10:24:09 AM9/6/13
to google-analytics...@googlegroups.com
Thanks, will do.
To unsubscribe from this group and all its topics, send an email to google-analytics-data-export-api+unsubscribe@googlegroups.com.

Arslan haktic

unread,
May 10, 2014, 10:07:56 AM5/10/14
to google-analytics...@googlegroups.com
Hi, I am also getting same errors while i am tryinng to get purchased item varification from google console using 
GET https://www.googleapis.com/androidpublisher/v1.1/applications/packageName/inapp/productId/purchases/token
i have obtained access token which is refreshed and updated, my google purchase is fully ok , i am putting correct information as arguments but still getting 
HTTP/1.1 403 Forbidden
Content-length: 166
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Expires: Sat, 10 May 2014 13:51:05 GMT
Server: GSE
Cache-control: private, max-age=0
Date: Sat, 10 May 2014 13:51:05 GMT
X-frame-options: SAMEORIGIN
Content-type: application/json; charset=UTF-8
{
 
"error": {
   
"code": 403,
   
"message": "Forbidden",
   
"errors": [
     
{
       
"domain": "global",
       
"message": "Forbidden",
       
"reason": "forbidden"
     
}
   
]
 
}
} Please help my in this i have wasted more then 2 days for this.

Prashanth Kumar

unread,
May 24, 2014, 12:37:30 PM5/24/14
to google-analytics...@googlegroups.com
I am facing the 403 forbidden error. I have created an executable, which takes date as an input and provide the results. It works fine in my local, but throw 403 forbidden error in server. 
Any ideas to this issue?
Reply all
Reply to author
Forward
0 new messages