2 回答
TA贡献1795条经验 获得超7个赞
尝试:
export JSON_CREDS="{\"type\":\"service_account\",\"project_id\":\"project-id\",\"private_key_id\":\"some_number\",\"private_key\":\"\",\"client_email\":\"<api-name>api@project-id.iam.gserviceaccount.com\",\"client_id\":\"...\",\"auth_uri\":\"https:\/\/accounts.google.com\/o\/oauth2\/auth\",\"token_uri\":\"https:\/\/accounts.google.com\/o\/oauth2\/token\",\"auth_provider_x509_cert_url\":\"https:\/\/www.googleapis.com\/oauth2\/v1\/certs\",\"client_x509_cert_url\":\"https:\/\/www.googleapis.com\/...<api-name>api%40project-id.iam.gserviceaccount.com\"}"
...
import "google.golang.org/api/option"
...
app, err := firebase.NewApp(context.Background(), nil, option.WithCredentialsJSON([]byte(os.Getenv("JSON_CREDS"))))
TA贡献1951条经验 获得超3个赞
我仅使用转义特殊字符的文件内容时遇到问题。对我来说,解决了获取整个有效负载并编码为 Base64,然后我设置为环境变量并在客户端启动中使用。
sdk, _ := b64.StdEncoding.DecodeString(os.Getenv("FIREBASE_SDK"))
opt := option.WithCredentialsJSON(sdk)
app, err := firebase.NewApp(context.Background(), nil, opt)
这种方式对我有用
- 2 回答
- 0 关注
- 189 浏览
添加回答
举报