I would like to show Google Analytics data (for android app) on my GAE web page. I've done the following:
mya...@appspot.gserviceaccount.com to my Google Analytics.The following code:
credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/analytics.readonly')
http = credentials.authorize(httplib2.Http(memcache))
service = build('analytics', 'v3', http=http)
response1 = service.management().accounts().list().execute()
response2 = service.data().ga().get(
ids='ga:45112345', # my profile id
start_date='2014-04-07',
end_date='2014-04-07',
metrics='ga:visits').execute()
returns the following responses:
{
u'username':u'mya...@appspot.gserviceaccount.com',
u'kind':u'analytics#accounts',
u'items':[
{
u'kind':u'analytics#account',
u'name':u'myapp - android',
u'created': u'2013-10-25T18:31:11.271 Z',
u'updated': u'2013-10-25T18:31:11.271 Z',
u'childLink':{
u'href': u'https://www.googleapis.com/analytics/v3/management/accounts/45112345/webproperties',
u'type':u'analytics#webproperties'
},
u'id':u'45112345',
u'selfLink': u'https://www.googleapis.com/analytics/v3/management/accounts/45112345',
u'permissions':{
u'effective':[
u'COLLABORATE',
u'EDIT',
u'MANAGE_USERS',
u'READ_AND_ANALYZE'
]
}
}
],
u'itemsPerPage':1000,
u'startIndex':1,
u'totalResults':1
}
<HttpError 403 when requesting https://www.googleapis.com/analytics/v3/data/ga?metrics=ga%3Avisits&alt=json&end-date=2014-04-07&ids=ga%3A45112345&start-date=2014-04-07 returned "User does not have sufficient permissions for this profile.">
Why do I get this User does not have sufficient permissions for this profile error? User has the full access to Google Analytics.
Actually I am just testing how it works. In result I would like to access the following data from Google Analytics: