首页 > 解决方案 > 设置 Heroku rails GOOGLE_APPLICATION_CREDENTIALS (firebase) 错误

问题描述

我有一个使用 firebase firestore 作为数据库应用程序的 rails 应用程序。在我运行这些命令后:

导出 GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"

要设置本地使用的凭据,该应用程序在本地运行良好。当我尝试在 heroku 服务器上部署时出现问题。当我运行 heroku run rails 控制台时,出现此错误:

/app/vendor/bundle/ruby/2.3.0/gems/googleauth-0.6.2/lib/googleauth/application_default.rb:61:in `get_application_default': Could not load the default credentials. Browse to (RuntimeError)
https://developers.google.com/accounts/docs/application-default-credentials
for more information

然后我转到heroku仪表板,在配置变量上,首先将var GOOGLE_APPLICATION_CREDENTIALS设置为空值,然后在终端中运行:

heroku config:add GOOGLE_APPLICATION_CREDENTIALS="$(cat file/path/to/credential-file.json)"

运行 heroku run rails 控制台后仍然出现错误:

/app/vendor/bundle/ruby/2.3.0/gems/googleauth-0.6.2/lib/googleauth/credentials_loader.rb:83:in `rescue in from_env': Unable to read the credential file specified by GOOGLE_APPLICATION_CREDENTIALS: file { (RuntimeError) } does not exist

有什么帮助吗?我指的是这些指令:

https://cloud.google.com/docs/authentication/production

标签: ruby-on-railsfirebaseherokufirebase-authentication

解决方案


推荐阅读