【发布时间】:2021-09-16 17:26:30
【问题描述】:
我想在 Python 中创建一个 Google Cloud 函数来
- 连接到 Google Search Console API
- 提取数据
- 通过管道将其导入 BigQuery
我可以找到各种代码示例来通过 OAuth、密钥等进行身份验证和连接,但是这些似乎都适用于在 本地 运行的 Python 脚本,而不是在云中。 (我需要它在云中运行,无人值守)。
Google 文档说,在 Cloud Function 中,可以使用“应用程序默认凭据 (ADC) 自动查找您的服务帐户凭据”自动进行身份验证。
此代码示例例如连接到 Cloud Storage 并对其进行身份验证:
def implicit():
from google.cloud import storage
# If you don't specify credentials when constructing the client, the
# client library will look for credentials in the environment.
storage_client = storage.Client()
# Make an authenticated API request
buckets = list(storage_client.list_buckets())
print(buckets)
但是,我找不到任何有关如何创建将通过 ADC 机制进行身份验证的 Google Search Console 客户端的文档。
请帮忙!
【问题讨论】:
-
你好@little_edian。以下任何一个答案是否helped you?
标签: python google-cloud-functions google-search-api google-search-console