在您的 Package.swift
文件中,添加以下内容
.package(url: "https://github.com/vapor-community/google-cloud-kit.git", from: "1.0.0-alpha.1")
现在设置配置。
import GoogleCloudKit
let credentialsConfig = GoogleCloudCredentialsConfiguration(project: "myprojectid-12345", credentialsFile: "/path/to/service-account.json")
您可以选择注册一个空的 GoogleCloudCredentialsConfiguration()
并配置以下环境变量
export GOOGLE_PROJECT_ID=myprojectid-12345
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account.json
此外,您可以将您的服务帐户 JSON 文件的内容复制并粘贴为 GOOGLE_APPLICATION_CREDENTIALS
环境变量的值
export GOOGLE_APPLICATION_CREDENTIALS=[Valid Pasted JSON]