【发布时间】:2018-05-09 00:04:05
【问题描述】:
我想知道如何在 Google App Engine 标准环境中使用服务帐户。 我编写了一些如下代码来使用正确的 JSON 密钥文件访问 BigQuery。
from google.cloud import bigquery
....
bigquery_client = bigquery.Client.from_service_account_json(proper_path_to_json_key)
list(bigquery_client.list_datasets())
当我在本地 Python 解释器上运行代码时,它运行正常,但在本地 dev_appserver.py 上运行时,结果惨遭失败并出现以下错误。
TransportError: ('Connection aborted.', error(13, 'Permission denied'))
当它在 GAE 上运行时,它仍然失败,但它的错误消息如下所示。
TransportError: ('Connection broken: IncompleteRead(208 bytes read)', IncompleteRead(208 bytes read))
我认为这个错误是由 GAE 对此处描述的出站流量的限制引起的 https://cloud.google.com/appengine/docs/standard/python/issue-requests 但我不知道如何解决它。
在 GAE 环境中使用服务帐户的最佳方式是什么?
【问题讨论】:
标签: python google-app-engine google-cloud-platform service-accounts