Search code examples
ruby-on-railsrubyauthenticationgoogle-cloud-storagefog

Authenticating with service account (email & key) in fog-google


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: 'xxxxxxxxxxxxx-yyyyyyyyyyyyy@developer.gserviceaccount.com', google_key_location: 'private/google-cloud-service-key.p12' )


Solution

  • 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.