In my Rails app I want to use the Twitter gem for accessing the Twitter API. I'm storing the OAuth secrets in a file under config/initializers/twitter.rb
Since I want to put the code in a public repository on Github my first reaction was to incude the file in gitignore
. However, this solution does not work with hosting on Heroku, which requires a git repository that includes the secrets.
Loading the OAuth secrets from environment variables using something like Dotenv ( https://github.com/bkeepers/dotenv ) would allow you to set and use them locally and in Heroku without having to store them in a file. See https://devcenter.heroku.com/articles/config-vars for setting env variables in Heroku.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.