Ryan Marshall
Ryan Marshall

Reputation: 31

Google APIs Explorer - Google Analytics - v3 - "401 Unauthorized"

i'm using the Explorer to just test out the API and get a feel for the data returned. On the top right corner of each API there is an "authorize using" switch. This asks me to auth with my google account. This all happens correctly and without error. When i try to use the "data.ga.get" method i get this error:

Request

GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key={YOUR_API_KEY}

Request

GET https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A24351574&start-date=2011-01-01&end-date=2012-02-01&metrics=ga%3Apageviews&pp=1&key={YOUR_API_KEY}

Authorization:  OAuth ya29.AHES6ZSCqka0X1AVtMrW7iXn7VreLk71vfWB9MrnXCejBYY
X-JavaScript-User-Agent:  Google APIs Explorer
Response

403 Forbidden

cache-control:  private, max-age=0
content-type:  application/json; charset=UTF-8
date:  Tue, 28 Feb 2012 01:23:18 GMT
expires:  Tue, 28 Feb 2012 01:23:18 GMT
server:  GSE
{
 "error": {
  "errors": [
   {
    "message": "Forbidden"
   }
  ],
  "code": 403,
  "message": "Forbidden"
  }
}

The strange thing is the auth works just fine for other API like calendar. I'm not sure what i'm missing that would case this issue

Upvotes: 2

Views: 2522

Answers (1)

jk.
jk.

Reputation: 14435

A 401 Unauthorized and a 403 Forbidden are two different errors. But, make sure the Analytics service is turned on for your project in the API console: https://code.google.com/apis/console/. enter image description here

Upvotes: 1

Related Questions