Google Analytics API get visits

937 views
Skip to first unread message

Ádám Bíró

unread,
Feb 3, 2014, 1:43:44 PM2/3/14
to google-analytics...@googlegroups.com
 Hi,

 I'm sorry for the question but I have read lot of forums and comments but I have not get the answer.
 I have created a basic code that should response a number of the visits, but I always get the same answer. 
 Both in my app and in OAuth 2.0 Playground.
 The response is: error=insufficient_scope. The full response from Playground:
 HTTP/1.1 403 Forbidden 
 Content-length: 232
 X-xss-protection: 1; mode=block
 X-content-type-options: nosniff 
 Expires: Mon, 03 Feb 2014 17:23:17 GMT 
 Server: GSE
 Cache-control: private, max-age=0
 Date: Mon, 03 Feb 2014 17:23:17 GMT
 X-frame-options: SAMEORIGIN
 Content-type: application/json; charset=UTF-8
 Www-authenticate: Bearer realm="https://www.google.com/accounts/AuthSubRequest", error=insufficient_scope, scope="https://www.googleapis.com/auth/analytics"
 {"error":{"errors":[{"domain":"global","reason":"insufficientPermissions","message":"User does not have sufficient permissions for this profile."}],"code":403,"message":"User does not have sufficient permissions for this profile."}}

 Four scopes are available to execute this line according to the OAuth 2.0 Playground (but might there are others because there is a field too):
 
 https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXXXXX&start-date=2014-01-03&end-date=2014-02-03&metrics=ga:visits,ga:bounces

 I have add the developer emails for the Client ID for web application and for the Compute Engine and App Engine as well to the site account in Analytic that has the XXXXXXXX id, but I always get this answer. Anyway different queries works properly.
 
 What should I do to make it work?
 
What can be the problem?

 Many thanks,
 Adam

Ádám Bíró

unread,
Feb 4, 2014, 5:42:15 AM2/4/14
to google-analytics...@googlegroups.com
The application response with this:

array(3) {
  ["access_token"]=>
  string(69) "ya29.1.AADtN_WKNlayPFxIj4XKbCwltkCPlPo4HAZRkH77GTWw1GZ0DYkotM_LKQ0xWg"
  ["token_type"]=>
  string(6) "Bearer"
  ["expires_in"]=>
  int(3600)
}
array(1) {
  ["error"]=>
  array(3) {
    ["errors"]=>
    array(1) {
      [0]=>
      array(3) {
        ["domain"]=>
        string(6) "global"
        ["reason"]=>
        string(23) "insufficientPermissions"
        ["message"]=>
        string(59) "User does not have sufficient permissions for this profile."
      }
    }
    ["code"]=>
    int(403)
    ["message"]=>
    string(59) "User does not have sufficient permissions for this profile."
  }

Linda Lawton

unread,
Feb 12, 2014, 6:31:39 AM2/12/14
to google-analytics...@googlegroups.com
The problem is that you need to have authentication before you can request information from the API.   https://developers.google.com/accounts/docs/OAuth2


If you are using this https://developers.google.com/oauthplayground/ playground make sure that you click the "authorize apis' button in step 1.  

nelssen....@gmail.com

unread,
Jul 15, 2015, 10:57:21 AM7/15/15
to google-analytics...@googlegroups.com
Hello Linda,

Im getting this same error in OAuth2 Playground, My application always get  
{"error":{"errors":[{"domain":"global","reason":"insufficientPermissions","message":"User does not have sufficient permissions for this profile."}],"code":403,"message":"User does not have sufficient permissions for this profile."}}

I have clicked in the "authorize apis" and I have the email in the Google Analytics User Accounts with all the permission.

What could be going wrong?

Thanks in advance,
N
Reply all
Reply to author
Forward
0 new messages