简体   繁体   中英

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()
  1. You must use google.golang.org/grpc package

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

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM