2019-06-14 22:42
浏览 234

仅在Golang中使用环境变量初始化Firebase Admin SDK

I'm trying to initialize the Firebase Admin SDK, in go, using only environment variables (no access to a filesystem).

I have the service-account-file.json file, and can get it working locally via:

export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-file.json"


app, err := firebase.NewApp(context.Background(), nil)

However, I'd like to put the contents of service-account-file.json into an env var, and init the firebase Admin SDK with its value.

There is an open issue that claims you can do it via CredentialsFromJSON, however I can't quite figure it out.

Does anyone have this working? If so can you please provide an example?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在运行中仅使用环境变量(无法访问文件系统)初始化Firebase Admin SDK 。</ p>

我有< code> service-account-file.json </ code>文件,并可以通过以下方式使其在本地运行:</ p>

  export GOOGLE_APPLICATION_CREDENTIALS =“ / path / to / service-account-  file.json“ 
app,err:= firebase.NewApp(context.Background(),nil)
 </ code> </ pre> 

但是,我想将 service-account-file.json </ code>的内容放入一个env变量中,并使用其值初始化firebase Admin SDK。</ p> \ n

有一个未解决的问题要求您 可以通过 CredentialsFromJSON 完成,但是我不能 可以解决这个问题。</ p>

有人能用吗? 如果可以,请提供示例吗?</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题