简体   繁体   English

公用API访问不适用于数据存储区javascript API的gapi.client

[英]Public API access not working with gapi.client for datastore javascript API

I am new to google cloud datastore. 我是Google云数据存储的新手。 I am currently trying to query my dataset using the API key which I created at developers console. 我目前正在尝试使用在开发人员控制台创建的API密钥查询数据集。 Below is my code snippet to call the datastore API (I am using gapi.client): 下面是调用数据存储区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这样的用户权限

The Cloud Datastore API reads and writes private user data and so requires OAuth 2.0 credentials. Cloud Datastore API读写私有用户数据,因此需要OAuth 2.0凭据。 This page has additional information on how to do this using the JavaScript client. 此页面包含有关如何使用JavaScript客户端执行此操作的其他信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gapi.client未定义:secha touch 2应用程序中的Google plus API - gapi.client is undefined:Google plus api within a secha touch 2 application 带有变量的javascript驱动器api gapi客户端请求 - javascript drive api gapi client request with variable 如何从Java服务器将Google api access_token传递给gapi javascript客户端? - How can I pass a google api access_token from java server to gapi javascript client? gapi.client是未定义的— firefox附加SDK - gapi.client is undefined — firefox add-on sdk 如何从gapi.client端点获取响应头 - How to get the response headers from gapi.client endpoints 有什么办法可以在多个页面上携带gapi.client对象? - Any way to carry the gapi.client object on multiple pages? 如果服务不可用,gapi.client是否应该正常失败? - Should gapi.client fail gracefully if the service is unavailable? 无法读取未定义的 gapi.client 的属性“init” - Cannot read property 'init' of undefined gapi.client 为什么会出现gapi.client未定义错误? - Why am I getting a gapi.client undefined error? 使用现有访问令牌通过Google的gapi库进行的授权客户端JS API调用? - Authorized client-side JS API calls with Google's gapi library with an existing access token?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM