javascript - Google Analytics API - Authorization on Analytics Properties -


i'm using google analytics api. need know if exists function returns me boolean value (or that) telling me if logged google account has rights show charts, didn't find similar in api.

so tried different, tried handle error when draw charts function execute(), using callback explained here: https://developers.google.com/analytics/devguides/reporting/core/v3/coredevguide#build-a-core-reporting-api-query code doesn't call callback.

here code:

var datachart = new gapi.analytics.googlecharts.datachart({     query: {       ids: ga_property_id,       metrics: 'ga:sessions, ga:users',       dimensions: 'ga:date',     },     chart: {       container: 'chart-container',       type: 'line',       options: {         width: '100%',         fontsize: 14       }     } });  function makeapicall() {     datachart.set({query: daterange});     datachart.execute(handlecorereportingresults); }  function handlecorereportingresults(results) {     if (!results.error)      {         console.log("success");     }      else      {         console.log("fail");     } }  makeapicall(); 

i tried put execute() try/catch works without catch, guess because exception comes gapi.

finding way know if logged user has rights on property better, fixing code , make works!

thanks in advance!

you call accounts summaries api , find complete list of accounts user has access.

summary = gapi.client.analytics.management.accountsummaries.list(); 

and loop results verify property or view among list.

but include view selector component , in way ever using view ids user has access.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -