用于Google AnalyticsAPI的OAuth2令牌

时间:2022-11-05 15:16:52

I have a site that I have tagged using Google Analytics. I can see that the stats are being created and I can analyse them using Google Analytics web tool.

我有一个使用Google Analytics标记的网站。我可以看到正在创建统计数据,我可以使用Google Analytics网络工具对其进行分析。

I want to extract my tagging data using the Google Analytics API but all the instructions seem to point me towards the developers console to create my OAuth2 token. My site does not appear in the list of apps that is presented, so I can't do the next step of generating my OAuth2 token.

我想使用Google AnalyticsAPI提取我的标记数据,但所有说明似乎都指向开发人员控制台以创建我的OAuth2令牌。我的网站未显示在所显示的应用列表中,因此我无法执行生成OAuth2令牌的下一步。

I feel like I must be missing something obvious, but I am hitting brick wall at the moment. How do I get the site to appear so I can see it in the developers console?

我觉得我必须遗漏一些明显的东西,但此刻我正在撞砖墙。如何让网站显示,以便我可以在开发者控制台中看到它?

1 个解决方案

#1


The Google Developer console is for registering your application, this way google knows who is using there APIs. Your Google analytics account wont show up here because well that's not how it works.

Google Developer控制台用于注册您的应用程序,谷歌知道谁在使用这些API。您的Google分析帐户不会显示在此处,因为这不是它的工作原理。

Create a new project you will get a client_id and client secrete that are used to identify your application. Then you use a programming language to access the API using the client id and client secret.

创建一个新项目,您将获得一个client_id和客户端secrete,用于标识您的应用程序。然后使用编程语言使用客户端ID和客户端密钥访问API。

I am not a java programmer so i cant help you with that. You mentioned that you want to access your own data. I recommend you look in to using a service account. A service account can be used to grant authentication without having to prompt a user for access. This only works when it is your own account you are accessing and the data doesn't belong to another user. Take the service account email address and add it as a user in google analytics at the ACCOUNT level it must be the Account level. then when you use the service account in your code you will have access.

我不是一个java程序员,所以我无法帮助你。您提到要访问自己的数据。我建议您查看使用服务帐户。服务帐户可用于授予身份验证,而无需提示用户进行访问。这仅在您访问自己的帐户且数据不属于其他用户时才有效。获取服务帐户电子邮件地址,并将其作为用户添加到帐户级别的Google Analytics中,并且必须是帐户级别。然后,当您在代码中使用服务帐户时,您将拥有访问权限。

https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-java

#1


The Google Developer console is for registering your application, this way google knows who is using there APIs. Your Google analytics account wont show up here because well that's not how it works.

Google Developer控制台用于注册您的应用程序,谷歌知道谁在使用这些API。您的Google分析帐户不会显示在此处,因为这不是它的工作原理。

Create a new project you will get a client_id and client secrete that are used to identify your application. Then you use a programming language to access the API using the client id and client secret.

创建一个新项目,您将获得一个client_id和客户端secrete,用于标识您的应用程序。然后使用编程语言使用客户端ID和客户端密钥访问API。

I am not a java programmer so i cant help you with that. You mentioned that you want to access your own data. I recommend you look in to using a service account. A service account can be used to grant authentication without having to prompt a user for access. This only works when it is your own account you are accessing and the data doesn't belong to another user. Take the service account email address and add it as a user in google analytics at the ACCOUNT level it must be the Account level. then when you use the service account in your code you will have access.

我不是一个java程序员,所以我无法帮助你。您提到要访问自己的数据。我建议您查看使用服务帐户。服务帐户可用于授予身份验证,而无需提示用户进行访问。这仅在您访问自己的帐户且数据不属于其他用户时才有效。获取服务帐户电子邮件地址,并将其作为用户添加到帐户级别的Google Analytics中,并且必须是帐户级别。然后,当您在代码中使用服务帐户时,您将拥有访问权限。

https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-java