Ian Davis
Ian Davis

Reputation: 19443

How do I provide auth data for Firebase Firestore rest api call

Here is my REST API GET: https://firestore.googleapis.com/v1beta1/projects/{myProjectId}/databases/(default)/documents/books

My goal is of course to retrieve documents from my books collection. The REST API docs are not great. I understand how to get an access_token given the Firestore scope, but how do I actually provide that in the GET? Do I do Bearer {access_token} as Authorization header? Do I also provide api={apiKey} as a query string param? Thanks.

Upvotes: 1

Views: 538

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50930

You just need to add the authorization header. Here's a curl request for the same:

curl --request GET \
  --url 'https://firestore.googleapis.com/v1beta1/projects/[PROJECT_ID]/databases/(default)/documents/books' \
  --header 'authorization: Bearer [ACCESS_TOKEN]'

If you still get 403 - Forbidden errors, then the token maybe expired or the security rules don't allow the read operaion.

Upvotes: 1

Related Questions