2015-09-10 17 views
1

我一直得到Missing required arguments: google_storage_access_key_id, google_storage_secret_access_key。我知道我應該將我的憑證放在「/.fog」文件中,但我不太瞭解應該如何在Rails應用程序的上下文中工作。有人可以詳細說明如何配置此?我嘗試在初始化程序中傳遞設置(如建議here),但它們似乎在validate_options方法中不被識別。使用服務帳戶(電子郵件和密鑰)進行身份驗證 - 谷歌

配置/初始化/ fog.rb GoogleStorage = Fog::Storage.new( provider: 'Google', google_project: 'xxxxxxxxxxxxx', google_client_email: '[email protected]', google_key_location: 'private/google-cloud-service-key.p12' )

回答

1

原來,這是目前不可能與fog-google寶石。請參閱this Github issue。當更新gem來處理這種認證策略時,我會更新這個答案。

0

使用Figaro Gem,而不是處理任何ENV瓦爾要存儲和用戶在整個應用程序安全。

添加費加羅到你的Gemfile和bundle install

gem "figaro"

費加羅的安裝很簡單:

$ bundle exec figaro install

這將創建一個註釋config/application.yml文件,並將其添加到 您的.gitignore。添加你自己的配置到這個文件,你完成了 !

例application.yml文件

# config/application.yml 

GOOGLE_ID: "ID" 
GOOGLE_KEY: "KEY" 

THEN配置/初始化/ fog.rb

GoogleStorage = Fog::Storage.new(
    provider: 'Google', 
    google_project: 'xxxxxxxxxxxxx', 
    google_client_email: '[email protected]', 
    google_key_location: Rails.root.join('private','google-cloud-service-key.p12'), 
    google_storage_secret_access_key_id: ENV["GOOGLE_ID"], 
    google_storage_secret_access_key: ENV["GOOGLE_KEY"] 
) 
+1

問題是我根本不想使用access_key。我不必在我的Node應用程序中; p12/pem + client_email就足夠了。 –

相關問題