Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback :set_user_by_token has not been defined #649

Closed
augustosamame opened this issue May 30, 2016 · 1 comment
Closed

callback :set_user_by_token has not been defined #649

augustosamame opened this issue May 30, 2016 · 1 comment

Comments

@augustosamame
Copy link

I am using setup devise_token_auth for an API backend to a mobile app.
I am using:
devise (4.0.3)
devise_token_auth (0.1.37)
omniauth (1.3.1)
omniauth-facebook (3.0.0)
Rails 5.0.0.rc1 with API-only option

Everything works fine with email as a provider

In order to properly implement Facebook login in the client, and still be able to authenticate on the server, I am following the method indicated in the omniauth-gem:

https://github.com/mkdynamic/omniauth-facebook
See Section: Client-side Flow with Facebook Javascript SDK

which basically says to handle all login in the client, and once the user logins, redirect the client to the API callback URL at auth/facebook/callback and let Omniauth parse the signed cookie.
Since I am using devise_token_auth, at this point the gem should suppossedly generate a token and login with provider:facebook instead of provider:email.

First I had to turn on sessions in the middleware since omniauth needs them for some reason.

But now my problem is that I am getting this error when calling GET auth/facebook/callback regardless of any parameters/cookies being present:

ArgumentError (Before process_action callback :set_user_by_token has not been defined)

Full stack trace follows.
Any help would be appreciated.

Started GET "/auth/facebook/callback" for 127.0.0.1 at 2016-05-30 14:43:47 -0500
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"

ArgumentError (Before process_action callback :set_user_by_token has not been defined):

activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:641:in block (2 levels) in skip_callback' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:637:ineach'
activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:637:in block in skip_callback' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:568:inblock in **update_callbacks'
activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:566:in reverse_each' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:566:in__update_callbacks'
activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:636:in skip_callback' actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:210:inblock (3 levels) in module:ClassMethods'
actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:93:in block in _insert_callbacks' actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:92:ineach'
actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:92:in _insert_callbacks' actionpack (5.0.0.rc1) lib/abstract_controller/callbacks.rb:209:inblock (2 levels) in module:ClassMethods'
devise_token_auth (0.1.37) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:5:in <class:OmniauthCallbacksController>' devise_token_auth (0.1.37) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:2:inmodule:DeviseTokenAuth'
devise_token_auth (0.1.37) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:1:in <top (required)>' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:477:inload'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:477:in block in load_file' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:662:innew_constants_in'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:476:in load_file' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:375:inblock in require_or_load'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:37:in block in load_interlock' activesupport (5.0.0.rc1) lib/active_support/dependencies/interlock.rb:12:inblock in loading'
activesupport (5.0.0.rc1) lib/active_support/concurrency/share_lock.rb:117:in exclusive' activesupport (5.0.0.rc1) lib/active_support/dependencies/interlock.rb:11:inloading'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:37:in load_interlock' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:358:inrequire_or_load'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:511:in load_missing_constant' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:203:inconst_missing'
activesupport (5.0.0.rc1) lib/active_support/inflector/methods.rb:270:in const_get' activesupport (5.0.0.rc1) lib/active_support/inflector/methods.rb:270:inblock in constantize'
activesupport (5.0.0.rc1) lib/active_support/inflector/methods.rb:266:in each' activesupport (5.0.0.rc1) lib/active_support/inflector/methods.rb:266:ininject'
activesupport (5.0.0.rc1) lib/active_support/inflector/methods.rb:266:in constantize' activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:583:inget'
activesupport (5.0.0.rc1) lib/active_support/dependencies.rb:614:in constantize' actionpack (5.0.0.rc1) lib/action_dispatch/http/request.rb:93:incontroller_class'
actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:44:in controller' actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:30:inserve'
actionpack (5.0.0.rc1) lib/action_dispatch/routing/mapper.rb:16:in block in <class:Constraints>' actionpack (5.0.0.rc1) lib/action_dispatch/routing/mapper.rb:46:inserve'
actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:39:in block in serve' actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:ineach'
actionpack (5.0.0.rc1) lib/action_dispatch/journey/router.rb:26:in serve' actionpack (5.0.0.rc1) lib/action_dispatch/routing/route_set.rb:725:incall'
actionview (5.0.0.rc1) lib/action_view/digestor.rb:12:in call' omniauth (1.3.1) lib/omniauth/strategy.rb:186:incall!'
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in call' omniauth (1.3.1) lib/omniauth/strategy.rb:186:incall!'
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in call' omniauth (1.3.1) lib/omniauth/builder.rb:63:incall'
rack-attack (4.4.1) lib/rack/attack.rb:100:in call' rack (2.0.0.rc1) lib/rack/session/abstract/id.rb:222:incontext'
rack (2.0.0.rc1) lib/rack/session/abstract/id.rb:216:in call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/cookies.rb:613:incall'
warden (1.2.6) lib/warden/manager.rb:35:in block in call' warden (1.2.6) lib/warden/manager.rb:34:incatch'
warden (1.2.6) lib/warden/manager.rb:34:in call' rack (2.0.0.rc1) lib/rack/etag.rb:25:incall'
rack (2.0.0.rc1) lib/rack/conditional_get.rb:25:in call' rack (2.0.0.rc1) lib/rack/head.rb:12:incall'
activerecord (5.0.0.rc1) lib/active_record/migration.rb:552:in call' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:38:inblock in call'
activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:97:in __run_callbacks**' activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:750:in _run_call_callbacks'
activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:90:inrun_callbacks' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:36:in call'
actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:incall' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:79:in call'
actionpack (5.0.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:49:incall' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:31:in call'
railties (5.0.0.rc1) lib/rails/rack/logger.rb:36:incall_app' railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in block in call'
activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:inblock in tagged' activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:intagged' railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in call'
actionpack (5.0.0.rc1) lib/action_dispatch/middleware/request_id.rb:24:incall' rack (2.0.0.rc1) lib/rack/runtime.rb:22:in call'
activesupport (5.0.0.rc1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall' actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:in call'
actionpack (5.0.0.rc1) lib/action_dispatch/middleware/static.rb:136:incall' rack (2.0.0.rc1) lib/rack/sendfile.rb:111:in call'
rack-cors (0.4.0) lib/rack/cors.rb:80:incall' railties (5.0.0.rc1) lib/rails/engine.rb:522:in call'
puma (3.4.0) lib/puma/configuration.rb:224:incall' puma (3.4.0) lib/puma/server.rb:569:in handle_request'
puma (3.4.0) lib/puma/server.rb:406:inprocess_client' puma (3.4.0) lib/puma/server.rb:271:in block in run'
puma (3.4.0) lib/puma/thread_pool.rb:114:in`block in spawn_thread'

@augustosamame
Copy link
Author

Using the latest master from Github directly in Gemfile solves this:

gem 'devise_token_auth', :git => 'git://github.com/lynndylanhurley/devise_token_auth.git'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant