Reputation: 2383
I keep getting Missing required arguments: google_storage_access_key_id, google_storage_secret_access_key
. I understand that I am supposed to put my credential "in a /.fog" file, but I don't quite understand how that's supposed to work in the context of a Rails app. Can someone elaborate on how to configure this? I have tried passing the settings in an initializer (as suggested here), but they don't seem to get recognized in the validate_options method.
config/initializers/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'
)
Upvotes: 1
Views: 1035
Reputation: 2383
Turns out this is not currently possible with the fog-google
gem. See this Github issue. I will update this answer when the gem is updated to handle this authentication strategy.
Upvotes: 1
Reputation: 4404
Use the Figaro Gem instead to handle any ENV vars you want to store and user throughout the app securely.
Add Figaro to your Gemfile and
bundle install
:
gem "figaro"
Figaro installation is easy:
$
bundle exec figaro install
This creates a commented
config/application.yml
file and adds it to your .gitignore. Add your own configuration to this file and you're done!
Example application.yml File
# config/application.yml
GOOGLE_ID: "ID"
GOOGLE_KEY: "KEY"
THEN config/initializers/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"]
)
Upvotes: 0