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):
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.
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
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.