We've moved discussions to Discord

Credentials returning nil in console

Charlie
Spent days on this issue but no luck. Any help, please?

EDITOR="atom --wait" rails credentials:edit --environment=development

# aws:
#   access_key_id: 123
#   secret_access_key: 345

Edited and saved
  aws:
    access_key_id: hgggtgggg
    secret_access_key: ytyyyyuu

Rails.application.credentials.config
=> {:secret_key_base=>"yuyuuuuuu",
:access_token_encryption_key=>"2IApOWCV5q4EINWdolbeiJOBDCujpdPe8iFOuXZy/7M=",
:omniauth=>
  {:aws=>{:access_key_id=>"hgggtgggg", :secret_access_key=>"ytyyyyuu"}
}

Rails.application.credentials.secret_key_base
=> "yuyuuuuuu"
Rails.application.credentials[:aws]
=> nil
Rails.application.credentials.dig(:aws, :access_key_id)
=> nil
Donn Felker
Based upon the hierarchy shown in Rails.application.credentials.config (as you've shown above), shouldn't the call be: 
Rails.application.credentials[:omniauth][:aws]
Charlie
Many thanks, Donn. I have removed the "omniauth" out of the way and it works as I expected.
Charlie
Spent days on this issue but no luck. Any help, please?

EDITOR="atom --wait" rails credentials:edit --environment=development

# aws:
#   access_key_id: 123
#   secret_access_key: 345

Edited and saved
  aws:
    access_key_id: hgggtgggg
    secret_access_key: ytyyyyuu

Rails.application.credentials.config
=> {:secret_key_base=>"yuyuuuuuu",
:access_token_encryption_key=>"2IApOWCV5q4EINWdolbeiJOBDCujpdPe8iFOuXZy/7M=",
:omniauth=>
  {:aws=>{:access_key_id=>"hgggtgggg", :secret_access_key=>"ytyyyyuu"}
}

Rails.application.credentials.secret_key_base
=> "yuyuuuuuu"
Rails.application.credentials[:aws]
=> nil
Rails.application.credentials.dig(:aws, :access_key_id)
=> nil
Donn Felker
Based upon the hierarchy shown in Rails.application.credentials.config (as you've shown above), shouldn't the call be: 
Rails.application.credentials[:omniauth][:aws]
Charlie
Many thanks, Donn. I have removed the "omniauth" out of the way and it works as I expected.
Notifications
You’re not receiving notifications from this thread.
© 2022 Jumpstart Pro by GoRails, LLC