41.2. 身份验证配置
Google BigQuery 组件身份验证用于 GCP 服务帐户。如需更多信息,请参阅 Google Cloud Platform Auth 指南。
通过提供到 GCP 凭证文件位置的路径,可以显式设置 Google 安全凭证。
或者被隐式设置,连接工厂将退回到 应用程序默认凭证。
当您拥有 服务帐户密钥 时,您可以为应用程序代码提供身份验证凭据。Google 安全凭证可以通过组件端点设置:
String endpoint = "google-bigquery://project-id:datasetId[:tableId]?serviceAccountKey=/home/user/Downloads/my-key.json";
String endpoint = "google-bigquery://project-id:datasetId[:tableId]?serviceAccountKey=/home/user/Downloads/my-key.json";
如果您不想设置文件系统路径,您还可以使用身份验证凭证的 base64 编码内容。
String endpoint = "google-bigquery://project-id:datasetId[:tableId]?serviceAccountKey=base64:<base64 encoded>";
String endpoint = "google-bigquery://project-id:datasetId[:tableId]?serviceAccountKey=base64:<base64 encoded>";
或者通过设置环境变量 GOOGLE_APPLICATION_CREDENTIALS
:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/my-key.json"