Rails Facebook-omniauth, Devise - Why can't I use environment variables? -


i had omniauth devise working in app, moved facebook credentials environment variables, , i've checked in console make sure defined. started seeing show in server logs:

(facebook) callback phase initiated. facebook) authentication failure! invalid_credentials: oauth2::error, :  {"error":{"message":"error validating client secret.","type":"oauthexception","code":1}} 

when try have test users authenticate facebook. i've checked app_id , app_secret. both set , match credentials in fb developer dashboard.

i tried deleting facebook app , creating brand new 1 (updated id , secret).

i tried create new users hadn't authed omniauth yet, no luck.

lastly, tried reverting hardcoded facebook credentials. worked! why can't use environment variables these credentials? i'm using heroku, , double checked make sure set. used initializer in local environment, , correctly set there well.

here's implementation in callbacks controller: (note, use facebook optional integration after user has registered account.)

class vendors::omniauthcallbackscontroller < devise::omniauthcallbackscontroller     def facebook         @vendor = current_vendor         uid = request.env["omniauth.auth"]["uid"]         fb_token = request.env["omniauth.auth"]["credentials"]["token"]         @vendor.update_attributes(:uid => uid, :fb_token => fb_token)         redirect_to vendors_dashboard_path     end end 

any here appreciated. i'd prefer not hardcode credentials , check them source control if possible!

you trying request variables not same environment variables. can access environment variables through env hash. make sure present outputting them console puts env['key'].


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -