错误401使用javascript选择融合表时

时间:2015-09-08 11:31:41

标签: javascript google-api google-fusion-tables

以下是我从Fusion表中选择行的代码。我有错误401响应,即需要授权。怎么办?我找不到足够的添加它或者可能是我没有得到它:/ 任何帮助,将不胜感激。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Fusion Tables Layer Example: Basic JSONP Request</title>
    <style type="text/css">
      #map-canvas {
        height: 500px;
        width: 600px;
      }

      .store-name {
        font-weight: bold;
        margin: 10px 0px 0px 0px;
        padding: 0px;
      }

      .address, .delivers {
        margin: 0px;
        padding: 0px;
      }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="https://apis.google.com/js/plusone.js"></script>

    <script type="text/javascript">
      function initialize() {
        var query = "SELECT * FROM " +
            '15UY2pgiz8sRkq37p2TaJd64U7M_2HDVqHT3Quw';
        var encodedQuery = encodeURIComponent(query);
        // Construct the URL
        var url = 'https://www.googleapis.com/fusiontables/v2/query?sql=' + encodedQuery + '&key=AIzaSyC41SwODXKVFnY4UrgeRwYZk1Ah_7eLgkw';
        console.log(url);
        // Send the JSONP request using jQuery
        $.ajax({
          url: url,
          dataType: 'jsonp',
          type: 'GET',
          Authorization : 'Basic MTBiaXR0ZmF0aW1hQHNlZWNzLmVkdS5wazp0QHl5YkA5Mg==',
          success: function (data) {
          alert('in success function ');
            var rows = data['rows'];
            var ftData = document.getElementById('ft-data');
                console.log(data);
          }
        });
      }

    </script>
  </head>
  <body>

<button onclick="initialize();">Authorize</button>
    <div id="ft-data"></div>
  </body>
</html>

回复了回复:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Login Required",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Login Required"
 }
}

1 个答案:

答案 0 :(得分:0)

你的桌子是私密的,这就是为什么你这样做只是去桌面并点击分享按钮然后更改&#34;谁有权访问任何有链接的人都可以查看&#34;