公共API访问不使用gapi。datastore javascript API的客户端。

时间:2022-11-21 15:50:04

I am new to google cloud datastore. I am currently trying to query my dataset using the API key which I created at developers console. Below is my code snippet to call the datastore API (I am using gapi.client):

我是谷歌云数据存储的新成员。我目前正在尝试使用在开发人员控制台创建的API键查询我的数据集。下面是我调用datastore 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);}
        );
});

This returns me following response:

回复如下:

Response headers:

响应标头:

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

Response body:

身体反应:

Login Required

需要登录

Though it is mentioned here that one can access the data using public api, I am still not able to do so.

虽然这里提到可以使用公共api访问数据,但我仍然不能这样做。

Please help me with this. Let me know whether is it possible or is there any other way to retrieve data from datastore without requiring user permission like OAuth

请帮我一下。让我知道是否有可能或者是否有其他方法可以在不需要像OAuth这样的用户权限的情况下从datastore检索数据

1 个解决方案

#1


5  

The Cloud Datastore API reads and writes private user data and so requires OAuth 2.0 credentials. This page has additional information on how to do this using the JavaScript client.

云数据存储API读写私有用户数据,因此需要OAuth 2.0凭证。这个页面有关于如何使用JavaScript客户端进行此操作的附加信息。

#1


5  

The Cloud Datastore API reads and writes private user data and so requires OAuth 2.0 credentials. This page has additional information on how to do this using the JavaScript client.

云数据存储API读写私有用户数据,因此需要OAuth 2.0凭证。这个页面有关于如何使用JavaScript客户端进行此操作的附加信息。