Google Analytics:使用身份验证执行API

时间:2022-04-06 14:18:19

As per the querybuilder

根据querybuilder

My API URI looks:

我的API URI看起来像:

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:12134345&
   start-date=30daysAgo
   &end-date=yesterday&
   metrics=ga:pageviews,ga:pageValue,ga:entrances&
   dimensions=ga:pagePath,ga:daysSinceLastSession,ga:sessionCount,ga%3
   Abrowser,ga:city&filters=ga:pagePath==/home

But when i execute in my domain, it throws error as login required. So for that i also passed API-KEY as &key="****" to the above url. But still no success. Still i get the same error

但是当我在我的域中执行时,它会因为需要登录而抛出错误。所以为此我还将API-KEY作为&key =“****”传递给上面的url。但仍然没有成功。我仍然得到同样的错误

Am i missing something? Can i embed this results to embed-api in charts

我错过了什么吗?我可以将此结果嵌入到图表中的embed-api中

1 个解决方案

#1


The api key is different from the access token. If you use the Query Explorer you can check a box in the report to include the access token in the query URI, which will allow you to just paste it into your browser's address bar (note: access tokens expire after an hour).

api密钥与访问令牌不同。如果您使用查询资源管理器,则可以选中报告中的一个框以在查询URI中包含访问令牌,这样您就可以将其粘贴到浏览器的地址栏中(注意:访问令牌在一小时后过期)。

If you want to learn how to get an access token programmatically, you should check out the OAuth 2.0 section of the Google Developers site: https://developers.google.com/identity/protocols/OAuth2

如果您想了解如何以编程方式获取访问令牌,请查看Google Developers网站的OAuth 2.0部分:https://developers.google.com/identity/protocols/OAuth2

#1


The api key is different from the access token. If you use the Query Explorer you can check a box in the report to include the access token in the query URI, which will allow you to just paste it into your browser's address bar (note: access tokens expire after an hour).

api密钥与访问令牌不同。如果您使用查询资源管理器,则可以选中报告中的一个框以在查询URI中包含访问令牌,这样您就可以将其粘贴到浏览器的地址栏中(注意:访问令牌在一小时后过期)。

If you want to learn how to get an access token programmatically, you should check out the OAuth 2.0 section of the Google Developers site: https://developers.google.com/identity/protocols/OAuth2

如果您想了解如何以编程方式获取访问令牌,请查看Google Developers网站的OAuth 2.0部分:https://developers.google.com/identity/protocols/OAuth2