I am trying to setup Devise with omniauth to allow facebook logins via my rails app. I have read through several guides / SO questions and they point that I don't have the FACEBOOK_APP_ID
setup in an environment variable on the box which is running the rails app. Well I setup an environment variable on the production box from which the app is running under that particular user. I added the FACEBOOK_APP_ID
and the FACEBOOK_SECRET
environment variables to the .bashrc
and I put the app in development mode via the facebook apps page. I also checked the roles
section of the app via the developer apps portal on the facebook site, and my facebook account is set to Administrator
, so I'm a little perplexed as to why this isn't working. Currently I'm seeing something like this,
Asked
Active
Viewed 556 times
1

ipatch
- 3,933
- 8
- 60
- 99
-
Are you sure the variable is in the right .bashrc ? The one of the user that actually runs the instance of your rails server ? – Alexandre Voyer Jan 04 '16 at 00:01
-
Yes, I just doubled checked that, and puma is running under the user which deploys the app via capistrano, and I echoed `FACEBOOK_APP_ID` and it prints the hash of characters. – ipatch Jan 04 '16 at 00:03
-
1I recall having that same problem with one capistrano deployment and ended up using figaro gem to keep track of my global variables... It's probably not the answer you're looking for but maybe another way for you to get it done :) – Alexandre Voyer Jan 04 '16 at 00:06
-
1I recall that the capistrano instance that starts your server doesn't run bashrc when it logs in to your server since it doesn't run an interactive session. You can view a few solutions here: http://stackoverflow.com/questions/25479348/how-can-i-instruct-capistrano-3-to-load-my-shell-environment-variables-set-at-re – Alexandre Voyer Jan 04 '16 at 00:19
-
what does echo $FACEBOOK_APP_ID prints? in your terminal – Ccr Jan 04 '16 at 05:03
-
1you can use a nice gem call dotenv – Ccr Jan 04 '16 at 05:05
1 Answers
0
Simply don't use environment variables, let's suppose that my appid is 121 and secret is abc.
Then my omniauth.rb
will look like:
OmniAuth.config.logger = Rails.logger
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, "121", "abc"
end

Ali Sajid
- 3,964
- 5
- 18
- 33