Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Analytics API

Hi Google Team,

I am able to execute the below Google Analytics API in the Google Analytics-->Reporting--> Reporting APIv4

curl --request POST \
'https://analyticsreporting.googleapis.com/v4/reports:batchGet?key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"reportRequests":[{"viewId":"134778649","dateRanges":[{"endDate":"2023-11-30","startDate":"2010-11-01"}],"metrics":[{"expression":"ga:pageviews"}],"dimensions":[{"name":"ga:userAgeBracket"}]}]}' \
--compressed

But I am not able to get the same response from postman, I get the below error:

"message""Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
I have given the credentials in OAuth 2.0, I am not sure what I am missing. Please let me know if there is specific way to get this working from outside Google.

 

 

 

1 2 2,092
2 REPLIES 2