gpt4 book ai didi

javascript - Google Analytics Embed API - 未找到 OAuth 客户端

转载 作者:行者123 更新时间:2023-11-29 19:19:10 24 4
gpt4 key购买 nike

我正在尝试创建一个 API 来可视化谷歌分析数据。

当我运行这段代码时,它会出现一个橙色按钮 - 但单击它会生成“未找到 OAuth 客户端”。错误?

使用此代码作为示例。 https://ga-dev-tools.appspot.com/embed-api/basic-dashboard/

<html>
<head>

<script>
(function(w,d,s,g,js,fs){
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}};
js=d.createElement(s);fs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');};
}(window,document,'script'));
</script>

<script>

gapi.analytics.ready(function() {

/**
* Authorize the user immediately if the user has already granted access.
* If no access has been created, render an authorize button inside the
* element with the ID "embed-api-auth-container".
*/
gapi.analytics.auth.authorize({
container: 'embed-api-auth-container',
clientid: 'UA-104xxxx-x'
});


/**
* Create a new ViewSelector instance to be rendered inside of an
* element with the id "view-selector-container".
*/
var viewSelector = new gapi.analytics.ViewSelector({
container: 'view-selector-container'
});

// Render the view selector to the page.
viewSelector.execute();


/**
* Create a new DataChart instance with the given query parameters
* and Google chart options. It will be rendered inside an element
* with the id "chart-container".
*/
var dataChart = new gapi.analytics.googleCharts.DataChart({
query: {
metrics: 'ga:sessions',
dimensions: 'ga:date',
'start-date': '30daysAgo',
'end-date': 'yesterday'
},
chart: {
container: 'chart-container',
type: 'LINE',
options: {
width: '100%'
}
}
});


/**
* Render the dataChart on the page whenever a new view is selected.
*/
viewSelector.on('change', function(ids) {
dataChart.set({query: {ids: ids}}).execute();
});

});
</script>


</head>
<body>
<div id="embed-api-auth-container"></div>
<div id="chart-container"></div>
<div id="view-selector-container"></div>
</body>
</html>

最佳答案

clientid: 'UA-104xxxx-x'

客户端 ID 创建于 Google developer console看起来像这样

1046123799103-dmog5dt4cu055g7pf08gitv3i0rlni6f.apps.googleusercontent.com

网络 Assets ID 来自 Google Analyitcs 网站,看起来像这样

UA-104xxxx-x

Anwser:你发错了。 Create a New Client ID

关于javascript - Google Analytics Embed API - 未找到 OAuth 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33804102/

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