简体   繁体   English

我们应该如何创建凭证以通过Python连接到Google Analytics(分析)?

[英]How we should create the credential to connect to google analytics via Python?

I used the google Python example to connect to google analytics and collect all data. 我使用Google Python示例连接到Google Analytics(分析)并收集了所有数据。 I was able to connect and collect data when I use this example, but when I change the profile_id to select a different view, I got the following error: 使用此示例时,我能够连接并收集数据,但是当我更改profile_id以选择其他视图时,出现以下错误:

was: 是:

profile_id = get_first_profile_id(service)

now: 现在:

profile_id = '68444917

googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A168847831&start-date=2018-01-01&end-date=2019-02-01&metrics=ga%3Asessions%2Cga%3AtotalEvents%2Cga%3Ausers&dimensions=ga%3AeventAction%2Cga%3Adate%2Cga%3AcontentGroup2%2Cga%3AcontentGroup3&filters=ga%3AeventAction%3D%3DDealer+site&samplingLevel=HIGHER_PRECISION&include-empty-rows=true&start-index=1&max-results=10000&alt=json returned "User does not have sufficient permissions for this profile.">

The admin checked my permission based on questions 1 and 2 and it looks I have access to all views. 管理员根据问题12检查了我的许可,看来我有权访问所有视图。

It is needed the permission granted to the created email account by google analytics as mentioned here : 这是需要通过谷歌分析授予创建的电子邮件帐户的权限所提到这里

The newly created service account will have an email address that looks similar to:

quickstart@PROJECT-ID.iam.gserviceaccount.com
Use this email address to add a user to the Google analytics view you want to access via the API. For this tutorial only Read & Analyze permissions are needed.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Drive API for Python:如何创建凭证? - Google Drive API for Python: how to create credential? 如何在 Python 中使用服务帐户凭据创建 Google 表格? - How to create Google Sheets using Service Account Credential in Python? 如何通过 python 脚本添加登录凭据? - How to add login credential via python script? 如何使用Python连接到Netezza / PureData for Analytics - How to connect to Netezza/PureData for Analytics using Python 如何使用 python 运行包含多个项目的 SQL? (谷歌凭证问题) - How to run a SQL with multiple projects in it using python? (A google credential problem) 如何将 Google Console 项目与 Google Analytics 帐户连接 - How to connect Google Console Project with Google Analytics account 使用Python通过Cloudfunctions将Dialogflow与Google BigQuery连接 - Connect Dialogflow with Google BigQuery via Cloudfunctions with Python 我想创建一个用户凭据 python 脚本,其中数据存储在 csv 文件中,并且用户应该是唯一的 - I want to create a user credential python script wherein the data is stored in a csv file and the user should be unique 如何通过 Python 连接到 Bitbucket? - How to connect to Bitbucket via Python? 如何从Python触发Google Analytics事件? - How to trigger Google Analytics events from Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM