程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Google Analytics OAuth2 客户端 ID 本地主机大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Google Analytics OAuth2 客户端 ID 本地主机?

开发过程中遇到Google Analytics OAuth2 客户端 ID 本地主机的问题如何解决?下面主要结合日常开发的经验,给出你关于Google Analytics OAuth2 客户端 ID 本地主机的解决方法建议,希望对你解决Google Analytics OAuth2 客户端 ID 本地主机有所启发或帮助;

我正在尝试这个 Embed API 教程,它似乎对我不起作用: https://developers.google.com/analytics/devguides/reporTing/embed/v1/getTing-started

以下是我的代码,其中包含创建客户端 ID 的步骤:

<!DOCTYPE HTML>
<HTML>
    <head>
        <title>Embed API Demo</title>
    </head>
    <body>
        <!-- Step 1: Load the Embed API library. -->
        <script>
(function(w,d,s,g,Js,fJs){
  g=w.gAPI||(w.gAPI={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
  Js=d.createElement(s);fJs=d.getElementsByTagname(s)[0];
  Js.src='https://APIs.Google.com/Js/platform.Js';
  fJs.parentNode.insertBefore(Js,fJs);Js.onload=function(){g.load('analytics')};
}(window,document,'script'));
        </script>
        <!-- Step 2: Add HTML containers to host the dashboard components. -->
        <div ID="embed-API-auth-container"></div>
        <div ID="chart-container"></div>
        <div ID="vIEw-SELEctor-container"></div>
        <!-- Step 3: Write the dashboard code. -->
        <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: 'CLIENT ID' <!-- I put my actual clIEnt ID here in the file -->
  });


  /**
   * 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>
    </body>
</HTML>

我完美地遵循了这些步骤,但它没有在页面中呈现,而且我没有收到任何有用的错误,只有一个空白页面。

我的问题是:我必须在授权域上使用它吗?有授权的域步骤,但它不接受 localhost(当您只是尝试应用程序时,这没有意义)。所以我目前正在 localhost:5500/home.HTML 中打开这个文件。我在那里添加了我自己的 HTML 只是为了检查实际文件正在加载,它是。 Js 只是没有呈现,所以我假设这是我的客户端 ID 和授权域设置的问题?

有没有人有这方面的经验,可以建议一种在本地主机上测试 Google oauth2 功能的方法吗?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的Google Analytics OAuth2 客户端 ID 本地主机全部内容,希望文章能够帮你解决Google Analytics OAuth2 客户端 ID 本地主机所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。