jeygeethan / activestorage-backblaze

Looking for co-committers. Pls reach out. Activestorage (rails 6) gem for using backblaze b2 as the storage (just like aws s3 etc)
26 stars 10 forks source link

Fog::Errors::Error (B2 credentials are required) #1

Closed justalever closed 4 years ago

justalever commented 4 years ago

Hey @gten, Thanks for creating this gem!

It seemingly worked until I get an authorization issue.

Here are my logs if it helps:

Completed 500 Internal Server Error in 117ms (ActiveRecord: 3.0ms | Allocations: 144005)

Fog::Errors::Error (B2 credentials are required, please use b2_account_id and b2_account_token or b2_key_id and b2_key_token):

fog-backblaze (0.3.0) lib/fog/backblaze/storage/real.rb:419:in `auth_response'
fog-backblaze (0.3.0) lib/fog/backblaze/storage/real.rb:441:in `b2_command'
activestorage-backblaze (0.0.5) lib/active_storage/service/backblaze_service.rb:116:in `block in b2_get_upload_url'
fog-backblaze (0.3.0) lib/fog/backblaze/token_cache.rb:49:in `fetch'
activestorage-backblaze (0.0.5) lib/active_storage/service/backblaze_service.rb:114:in `b2_get_upload_url'
activestorage-backblaze (0.0.5) lib/active_storage/service/backblaze_service.rb:85:in `block in url_for_direct_upload'
activesupport (6.0.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.1) lib/active_support/notifications.rb:180:in `instrument'
activestorage (6.0.1) lib/active_storage/service.rb:126:in `instrument'
activestorage-backblaze (0.0.5) lib/active_storage/service/backblaze_service.rb:84:in `url_for_direct_upload'
activestorage (6.0.1) app/models/active_storage/blob.rb:160:in `service_url_for_direct_upload'
activestorage (6.0.1) app/controllers/active_storage/direct_uploads_controller.rb:19:in `direct_upload_json'
activestorage (6.0.1) app/controllers/active_storage/direct_uploads_controller.rb:9:in `create'

I have supplied the keyId and applicationKey for key_id and key_token parameters in my storage.yml as your readme described. Am I using the wrong keys here? It's rather confusing to know what to provide from Backblaze. Any help would be awesome!

jeygeethan commented 4 years ago

@justalever Have you referenced the yaml setting in the right places?

config.active_storage.service = :backblaze_dev should be present in 'config/environments/development.rb'

And in storage.yml

backblaze_dev:
  service: Backblaze
  bucket_name: <bucket_name>
  bucket_id: <bucket_id>
  key_id: <key_id>
  key_token: <key_token>

Likewise for other environments.

Let me know if you need further help.

jeygeethan commented 4 years ago

You need to use the key_id (instead of account_id) and key_token (instead of the account_token). You can follow this here: https://www.backblaze.com/blog/b2-application-keys/

Be sure to have the permissions for the bucket for this application key id.

justalever commented 4 years ago

I'll give this a shot! Thanks for the response