1

I'm trying to build a gRPC client for Google's Firestore API in Elixir.

Before starting to write some code , I thought that it would be wise to first start with BloomRPC in order to debug the issue.

enter image description here

As base url, I'm using https://firestore.googleapis.com where I pinned the rot certificate.

As auth I'm using an access_token obtained using oauth with the following 2 scopes: "https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/datastore" being passed as a Authorization header:

{
    "Authorization": "Bearer 29ya.a0AfH6SMBDYZPsVgQv0PMqyGRXypc3DfWF_2jbvAJKMquTaryCvxEB7X1Rbprfk1Ebrwid2bXbcR3Aw-d1Tytlo_lThkyqRDRIbnSz5-nQ3xWklkmjyFMAuQtFCoz01hk3vbgBwd2gdbFNNWiOU_8NqPC_vElyz2-cQ34"
}

And I get back:

{
  "error": "3 INVALID_ARGUMENT: Missing required project ID."
}

So clearly I should be passing the project ID somehow but I can't find it anywhere in the docs. Anybody any clues?

dunyakirkali
  • 369
  • 5
  • 16
  • Could you please share the code of how you are passing the headers or thr request you are making? Please also check this another [Stackoverflow post](https://stackoverflow.com/a/58444009/8791788) – Nibrass H Jun 02 '20 at 10:26
  • I'm using BloomRPC to make the call, just so that I can test it first. Just updated the question – dunyakirkali Jun 02 '20 at 10:36
  • I get the feeling that the JWT token I'm using should be encoding what the projectID is. Can anybody confirm that? – dunyakirkali Jun 02 '20 at 10:42
  • Could you please explain what do you mean by the that the JWT token you are using should be encoding what the Project ID is ? – Nibrass H Jun 03 '20 at 10:23
  • Using a JWT token, it is possible to encode some payload in the token. Currently I use the Oauth2 sandbox tool from google to generate a JWT token but I that I need to generate one in another manner so that I can specify the projectId in the payload of the JWT token. – dunyakirkali Jun 03 '20 at 11:20
  • Please have a look into this similar post in [Stackoverflow https://stackoverflow.com/questions/56090338/firebase-admin-nodejs-cannot-verify-auth-token-jwt). You can specify the project ID as following: { "parent": "Hello", "aud": "PROJECT_ID", "page_size": 10, "page_token: "hello" } – Nibrass H Jun 03 '20 at 15:54

1 Answers1

2

I just figured out what I was doing wrong.

Basically the Bearer token I was using is correct (obtained via the OAuth Playground).

The trick was to specify the PROJECT_ID in the parent parameter of the request:

{
  "parent": "projects/[project-id]/databases/(default)/documents",
  "page_size": 10
}

I should have just read the docs properly :)

dunyakirkali
  • 369
  • 5
  • 16