我是谷歌云数据存储的新手。我目前正在尝试使用我在开发人员控制台中创建的 API 密钥来查询我的数据集。下面是我调用数据存储 API 的代码片段(我使用的是 gapi.client):
gapi.client.setApiKey('API_KEY');
gapi.client.load('datastore', 'v1beta2').then(function() {
console.log('loaded.');
gapi.client.datastore.datasets.runQuery({'datasetId' : 'myProjectId','gqlQuery': { 'queryString': 'select * from locationReport'}}).then(function(resp) {
console.log(resp.result);
}, function(reason) {
console.log('Error: ' + reason.result.error.message);}
);
});
这将返回以下响应:
响应标头:
HTTP/1.1 401 Unauthorized
Vary: Origin
Vary: X-Origin
WWW-Authenticate: Bearer realm="https://accounts.google.com/"
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Date: Mon, 22 Jun 2015 14:49:06 GMT
Expires: Mon, 22 Jun 2015 14:49:06 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic,p=1
Transfer-Encoding: chunked
回复正文:
要求登录
虽然这里提到可以使用公共 api 访问数据,但我仍然无法这样做。
请帮我解决一下这个。让我知道是否有可能或有任何其他方式从数据存储中检索数据而无需像 OAuth 这样的用户许可