ruby on rails 4 - Getting Facebook callback error even after enabling 'Embedded browser OAuth Login' and specifying the callback url -


i have rails(4.2.0) application uses facebook login functionality. main gems devise(3.4.0) , omniauth-facebook(2.0.0). i have registered application on facebook , have been using test app development. facebook login functionality works in development env.

when trying use facebook login feature on production server, error "given url not allowed application configuration: 1 or more of given urls not allowed app's settings. must match website url or canvas url, or domain must subdomain of 1 of app's domains."

the details settings test app being used in dev env -

settings:   basic:     app domains: 'localhost'     website:       site url: 'http://localhost:3000'   advanced:     oauth settings:       embedded browser oauth login: yes       valid oauth redirect uris: "http://localhost:3000/users/auth/facebook/callback" 

the details settings registered app being used in production env -

settings:   basic:     app domains: 'www.mysite.co'     website:       site url: 'http://www.mysite.co'   advanced:     oauth settings:       embedded browser oauth login: yes       valid oauth redirect uris: "http://www.mysite.co/users/auth/facebook/callback" 

i have specified following in secrets.yml

development:   secret_key_base: some_secret_key    facebook:     app_id: test_app_id     app_secret: test_app_secret production:   secret_key_base: some_secret_key    facebook:     app_id: registered_app_id     app_secret: registered_app_secret 

and have been using creds secrets.yml in devise initialiser as

# ==> omniauth # add new omniauth provider. check wiki more information on setting # on models , hooks. # config.omniauth :github, 'app_id', 'app_secret', scope: 'user,public_repo' require 'omniauth-facebook' config.omniauth :facebook, rails.application.secrets.facebook['app_id'], rails.application.secrets.facebook['app_secret'], scope: ['user_photos', 'email', 'public_profile'] 

basic settings test app callback url test app basic settings app callback url app

the actual domain name(blackened) has no typos anywhere , same wherever used.

contains of routes.rb related omniauth as

 cat config/routes.rb  rails.application.routes.draw   root 'home#index'    devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }    # routes related other controllers end 

the routes below

bundle exec rake routes | grep user  new_user_session      /users/sign_in(.:format)                               devise/sessions#new user_session post     /users/sign_in(.:format)                               devise/sessions#create destroy_user_session delete   /users/sign_out(.:format)                              devise/sessions#destroy user_omniauth_authorize get|post /users/auth/:provider(.:format)                        users/omniauth_callbacks#passthru {:provider=>/facebook/} user_omniauth_callback get|post /users/auth/:action/callback(.:format)                 users/omniauth_callbacks#:action 

the code related omniauth in entire app as

$ cat app/controllers/users/omniauth_callbacks_controller.rb   class users::omniauthcallbackscontroller <  devise::omniauthcallbackscontroller   def facebook     #you need implement method below in model (e.g. app/models/user.rb)     @user = user.from_omniauth(request.env["omniauth.auth"])     if @user.persisted?       sign_in_and_redirect @user, event: :authentication #this   throw if @user not activated       set_flash_message(:notice, :success, kind: "facebook") if is_navigational_format?     else       session["devise.facebook_data"] = request.env["omniauth.auth"]       redirect_to new_user_registration_url     end   end end 

i don't have enough reputation comment. need change settings in facebook dev center match url of production site instead of localhost.

update url here:

enter url here


Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -