0

我正在使用简单的仪表板 java 脚本库显示折线图。但它会引发错误 401 login required。我在 Google 开发人员控制台中创建了项目并为其生成了密钥。正如 401 错误代码所解释的那样,凭据是错误的。告诉我出了什么问题。任何帮助将不胜感激。在此先感谢这是此代码

<!DOCTYPE>
<html>
<head><title>GA Dash Demo</title></head>
<body>

  <!-- Add Google Analytics authorization button -->
  <button id="authorize-button" style="visibility: hidden">
        Authorize Analytics</button>

  <!-- Div element where the Line Chart will be placed -->
  <div id='line-chart-example'></div>

  <!-- Load all Google JS libraries -->
  <script src="https://www.google.com/jsapi" type="text/javascript"></script>
    <script src="gadash-1.0.js" type="text/javascript"></script>
  <script src="https://apis.google.com/js/client.js?onload=gadashInit" type="text/javascript"></script>
  <script type="text/javascript">
        // Configure these parameters before you start.
    var API_KEY = 'AIzaSyA2LNhLKC4yvO9CmYXhp3tKjEvtd9GGZbc';
    var CLIENT_ID = '1096873113711-c8j9vt2ilnh6gbb0rshhfk3j89qv9pb5.apps.googleusercontent.com';
    var TABLE_ID = 'ga:91837123';
    // Format of table ID is ga:xxx where xxx is the profile ID.

    gadash.configKeys({
        'apiKey': API_KEY,
        'clientId': CLIENT_ID
    });

    // Create a new Chart that queries visitors for the last 30 days and plots
    // visualizes in a line chart.
    var chart1 = new gadash.Chart({
        'type': 'LineChart',
        'divContainer': 'line-chart-example',
        'last-n-days': 30,
        'query': {
            'ids': TABLE_ID,
            'metrics': 'ga:visitors',
            'dimensions': 'ga:date'
        },
        'chartOptions': {
            height: 600,
            title: 'Visits in January 2011',
            hAxis: { title: 'Date' },
            vAxis: { title: 'Visits' },
            curveType: 'function'
        }
    }).render();
  </script>
</body>
</html>
4

0 回答 0