Search code examples
ruby-on-rails-3carrierwavegoogle-cloud-storage

Storage Access Credentials for Google Storage for carrierwave gem in a Rails Application


In my rails 3 application, I am using carrierwave gem (version 0.5.6). I would like to use Google Storage for developers for storing the uploaded files. I have created an initalizer which looks like following:

CarrierWave.configure do |config|
    config.fog_credentials = {
        :provider                         => 'Google',
        :google_storage_access_key_id => 'xxxx',
        :google_storage_secret_access_key => 'yyyy'
    }
    config.fog_directory = 'directory'
end

I am getting 403 forbidden message with

...<Error><Code>InvalidSecurity</Code><Message>The provided security credentials are not valid.</Message>...

I have just enabled my Google Storage using the apis-console, and I can upload files using the online 'Google Storage Manager'. For 'google_storage_access_key_id' in the initializers file above, I am using 'Google Storage Id' for 'You' in the 'Storage Access' page. For 'google_storage_secret_access_key', I am using the 'Legacy storage access keys'.

I don't know how to proceed. Could someone kindly point me towards how to get about debugging this issue?

Thanks, Saksham


Solution

  • It sounds like you've enabled the legacy access keys for your account. From the Google APIs console select Google Storage and then click on legacy access.

    Use the access key from that page here:

    google_storage_access_key_id => 'xxxx',

    From the APIs console click show to display your secret key. Use that key here:

    google_storage_secret_access_key => 'yyyy'

    Do not use the Google ID for legacy access.

    Hope this helps,

    Anthony