Rails: Omniauth - "The parameter app_id is required"
facebook, omniauth, ruby, ruby-on-rails
Solution
Oh, now I see: you need to define environment variables to store your `facebook_app_id` and `facebook_secret`. You add them to your environment like this (assuming unix-like system):
Add this to the bottom of your `~/.bashrc` file (or equivalent):
export FACEBOOK_APP_ID='your_id_here'
export FACEBOOK_SECRET='your_secret_here'
Then open a new terminal to be sure they get loaded in the environment.
At last, in your `omniauth.rb` initializer you type exactly:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']
end
Read more about the topic here, for example.
You can also use dotenv gem to handle environment variables.
Problem
I'm following this railscast tutorial to set up omniauth for facebook authentication on my rails project: http://railscasts.com/episodes/360-facebook-authentication?autoplay=true. I'm 4 minutes in and all I've done so far is bundle the gem `omniauth-facebook` and added, omniauth.rb ``` OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, ENV['my id here...'], ENV['my secret code here...'] end ``` and then when I go to `http://localhost:3000/auth/facebook` I get an error saying `The parameter app_id is required`.