Created
October 17, 2023 15:22
-
-
Save jmound/e846cb7095ed5ff23e79cfbd25ed0047 to your computer and use it in GitHub Desktop.
querying firestore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There doesn't seem to be a gcloud method for querying firestore. | |
``` | |
ACCESS_TOKEN=$(gcloud auth application-default print-access-token) | |
``` | |
Make a request to Firestore API: Once you have your access token, you can make a GET request to the Firestore REST API to retrieve a document. The URL for the request should be in the following format: | |
https://firestore.googleapis.com/v1/projects/{project-id}/databases/(default)/documents/{collection-id}/{document-id} | |
``` | |
curl -X GET \ | |
'https://firestore.googleapis.com/v1/projects/my-project/databases/(default)/documents/my-collection/my-document' \ | |
-H "Authorization: Bearer $ACCESS_TOKEN" \ | |
-H "Accept: application/json" | |
``` | |
Note: the `#` character in the URL needs to be URL escaped by replacing it with `%23` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment