gpt4 book ai didi

node.js - Nodejs错误: "User does not have sufficient permissions for this profile "

转载 作者:太空宇宙 更新时间:2023-11-04 01:25:21 26 4
gpt4 key购买 nike

我有一个在 Google Analytics API 上运行查询的 Nodejs 代码,我使用 googleapis 库进行身份验证和获取数据。

但是,当我尝试发送查询以检索“页面 View ”时,例如,但最终我收到错误,就会出现问题。因此,我已将我的服务帐户的 client_email 添加到 Google Analytics(分析)中。

NodeJS 代码:

const scopes = ['https://www.googleapis.com/auth/analytics.readonly']

const jwt = new google.auth.JWT(keys.client_id, null, keys.private_key, scopes)


async function getData() {
const response = await jwt.authorize()
const result = await google.analytics('v3').data.ga.get({
'auth': jwt,
'ids': 'ga:146850375',
'start-date': '30daysAgo',
'end-date': 'today',
'metrics': 'ga:pageviews'
}).then( (res) => console.log(res) )
.catch( (e) => console.error(e) )


console.dir(result)
}

getData()

结果:

[1] : /image/zWJZm.png

最佳答案

解决方案:

实际上,帐户 ID(在“管理”->“帐户”->“帐户设置”下)并不是用作您的个人资料 ID 的正确数字。您必须使用要分析的特定 View ID。这些可能是相同的(有时),但它们也可能不同,因为这是我的情况。

关于node.js - Nodejs错误: "User does not have sufficient permissions for this profile ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57742976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com