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>[email protected]\",\"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 關注
- 234 瀏覽
添加回答
舉報