jipson
jipson

Reputation: 99

Firestore gRPC API Sample Usage in Golang

New to firestore and gRPC in general. I've been trying to figure out how to interact with the Firestore RPC API from golang. They document the API well here, but do not show how to initialize the connections. Some questions I have are,

  1. From golang, would I use the grpc package or the builtin rpc.
  2. What URL would I use to connect to the API.
  3. When connnecting to a cloud based RPC API like this, do I need to have the .proto files locally to be able to interact with it?
  4. How to authenticate with a users firebase ID token.
  5. How to create a record authenticated as said user.

Cheers.

Edit: I have been able to connect thanks to Anar. But I can't test anything because Im not really sure how to authenticate or create a record. Any help with an example would be great. Code so far:

conn, err := grpc.Dial("firestore.googleapis.com", grpc.WithInsecure())
if err != nil {
    log.Fatalln(err)
}
defer conn.Close()

Upvotes: 0

Views: 2743

Answers (1)

Anar Rzayev
Anar Rzayev

Reputation: 360

  1. You must use google.golang.org/grpc package

  2. As documentation you must use firestore.googleapis.com to create client stub.

enter image description here

3.You don't need it proto file locally. you can just create grpc client and use server methods which available here: https://cloud.google.com/firestore/docs/reference/rpc

Upvotes: 1

Related Questions