Google api 来自Storage.googleapis.com的Bigquery存储API gRPC http状态400

Google api 来自Storage.googleapis.com的Bigquery存储API gRPC http状态400,google-api,google-bigquery,grpc,google-api-client,google-api-python-client,Google Api,Google Bigquery,Grpc,Google Api Client,Google Api Python Client,我正在为R构建一个BigQuery存储客户端。其中的一部分涉及大量调试、编译、读取代码等 我正在尝试使用grpc\u cli复制基本的python示例,以了解为什么我的实现在使用python时被storage.googleapis.com拒绝。我想我明白我在发送什么。我认为它产生了相同的gRPC请求,但显然不是 我可能还是遗漏了什么,因为该死的googleapis服务器仍然返回400。我要做的是wireshark和嗅探数据包,但如果我不需要学习如何做,那就太好了 # export GRPC_TR

我正在为R构建一个BigQuery存储客户端。其中的一部分涉及大量调试、编译、读取代码等

我正在尝试使用
grpc\u cli
复制基本的python示例,以了解为什么我的实现在使用python时被storage.googleapis.com拒绝。我想我明白我在发送什么。我认为它产生了相同的gRPC请求,但显然不是

我可能还是遗漏了什么,因为该死的googleapis服务器仍然返回400。我要做的是wireshark和嗅探数据包,但如果我不需要学习如何做,那就太好了

# export GRPC_TRACE=all
# export GRPC_VERBOSITY=DEBUG

unset GRPC_TRACE
export GRPC_VERBOSITY=ERROR
export GOOGLE_APPLICATION_CREDENTIALS="bq-storage-dev.json"

grpc_cli call bigquerystorage.googleapis.com:443 google.cloud.bigquery.storage.v1.BigQueryRead/CreateReadSession --protofiles google/cloud/bigquery/storage/v1/storage.proto --proto_path ~/bigrquerystorage/inst/proto --channel_creds_type=gdc --json_output --binary_input --infile=~/request.bin --noremotedb --metadata=x-goog-request-params:read_session.table=projects/bigquery-public-data/datasets/usa_names/tables/usa_1910_current:x-goog-api-client:bigrquerystorage%20gl-r/4.0.3x86_64-pc-linux-gnu%20grpc/13.0.0_geeky%20gccl/0.2.0%20gargle/0.5.0
request.bin是会话对象的二进制内容

> serialize(session, NULL)
  [1] 0a 22 70 72 6f 6a 65 63 74 73 2f 6c 61 62 6f 2d 62 72 75 6e 6f 74 72 65 6d 62 6c 61
 [29] 79 2d 32 35 33 33 31 37 12 71 18 01 32 48 70 72 6f 6a 65 63 74 73 2f 62 69 67 71 75
 [57] 65 72 79 2d 70 75 62 6c 69 63 2d 64 61 74 61 2f 64 61 74 61 73 65 74 73 2f 75 73 61
 [85] 5f 6e 61 6d 65 73 2f 74 61 62 6c 65 73 2f 75 73 61 5f 31 39 31 30 5f 63 75 72 72 65
[113] 6e 74 42 23 0a 04 6e 61 6d 65 0a 06 6e 75 6d 62 65 72 0a 05 73 74 61 74 65 12 0c 73
[141] 74 61 74 65 20 3d 20 22 57 41 22 18 01
> rawToChar(serialize(session, NULL))
[1] "\n\"projects/labo-brunotremblay-253317\022q\030\0012Hprojects/bigquery-public-data/datasets/usa_names/tables/usa_1910_currentB#\n\004name\n\006number\n\005state\022\fstate = \"WA\"\030\001"
非常感谢您的帮助

编辑: 这将是Python的等效request.bin,工作正常

>>> from google.cloud.bigquery_storage_v1.types import storage
>>> request_serializer=storage.CreateReadSessionRequest.serialize
>>> request = storage.CreateReadSessionRequest(None)
>>> request.parent = parent
>>> request.read_session = requested_session
>>> request.max_stream_count = 1
>>> request_serializer(request)
b'\n"projects/labo-brunotremblay-253317\x12q\x18\x012Hprojects/bigquery-public-data/datasets/usa_names/tables/usa_1910_currentB#\n\x04name\n\x06number\n\x05state\x12\x0cstate = "WA"\x18\x01'

所以我想出了如何构建BigQuery存储R客户端。

使用grpc_cli访问BigQuery存储API是错误的做法

我需要使用protoc生成样板代码,然后根据生成的代码构建客户机


之后,需要将protobuf字段映射到R输入并添加正确的凭证生成器。

使用GRPC_TRACE=all激活两个跟踪后,我想我已经将其缩小到call.cc中的op序列。所以现在它起作用了,但我不明白为什么。这很好。