I am using postman to get data from my firestore api
https://firestore.googleapis.com/v1beta1/projects/myapp-ef511/databases/countries
but I am getting this,although my rules are public
{
"error": {
"code": 401,
"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 can I achieve this?I am planning to use retrofit in future.
Go to Firebase console and follow the below steps.
In General tab -> Under 'Your project' section it will show Project ID & Web API Key (will use it in url)
Now go to your Firestore database and get the document name e-g users
Finally just hit the below url with your desired values of Project ID, Web API Key and Document
https://firestore.googleapis.com/v1/projects/[Project ID]/databases/(default)/documents/[Document]?key=[Web API Key]
Example of real url:
https://firestore.googleapis.com/v1/projects/firestore-rest-api-test/databases/(default)/documents/players?key=AIzaSyDsCtB9PiFTtkJiDRmFEakbKvoohPRAGJU
NOTE: make sure you set your project rules on test mode to make it work. Otherwise use authentication first to make it work
The REST API requires either a Firebase Authentication ID token or Google Identity OAuth 2.0 token. The main difference between the two is that a Firebase Auth ID applies security rules and the Google ID does not. This guide on working with the Firestore REST API should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With