I want to build a simple rest API using Google Cloud Datastore and I can't access my data
First, I am new with Google Cloud Platform but this is not going to stop me until I find a solution on how to make a rest API call with Google Cloud Datastore.
I use Angular 4 in as front end and I want to make a simple HTTP request.
This is my data in Google Cloud Datastore
This is my api.service.ts
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Injectable()
export class ApiService {
private apiUrl1 = 'https://jsonplaceholder.typicode.com/posts';
private apiUrl2= 'https://datastore.googleapis.com/v1/projects/project-test:runQuery?key=dsdsdsdsdsdsdsdsdsdsdsds';
data: any = {};
constructor(
private http: Http
) { }
getData1() {
return this.http.get(this.apiUrl1)
.map((res: Response) => res.json()); <====== this works
}
getData2() {
const body = {
"query": {}
};
return this.http.post(this.apiUrl2, body)
.map((res: Response) => res.json()); <====== this dont works
}
}
I have this error
POST https://datastore.googleapis.com/v1/projects/project-test:runQuery?key=1b169abfa8b87ewewqewewqewqewqewqewqe 401 ()
Plese some expert tell me if I can access Google cloud datastore with rest API If yes why I have error 401 and why I need OAuth2
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",↵ "status": "UNAUTHENTICATED"↵ }↵}↵"
How the users can access my data. Some data is going to be publicly available
Any example how to access Cloud datastore with rest API is going to help us. I search the entire internet there is nothing . 0 Youtube videos And all documentations is with App engine . i use Firebase hosting - angular 4 and for the queries i want cloud datastore