I have several api's that I am integrating with and need to call in various parts of my application.
What is the way to store the keys, the user/password, or token information, say, a configuration file and then how do I call them for use in other parts of the application?
Thanks.
Instead of embedding your API keys in your applications, store them in environment variables or in files outside of your application's source tree.
Storage: API keys should not be stored as plain text but rather stored as a hashed value in the database to prevent copying. Even if an attacker successfully targets the key management database, the keys are unusable.
Just to keep this question up-to-date, there is a new way to do this in Rails 4.1:
From the Rails guides:
Rails 4.1 generates a new secrets.yml file in the config folder. By default, this file contains the application's secret_key_base, but it could also be used to store other secrets such as access keys for external APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With