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

NoMethodError (undefined method `client' for "<token>":String) #1375

Closed
dinhngochien opened this issue Jan 17, 2020 · 4 comments
Closed

NoMethodError (undefined method `client' for "<token>":String) #1375

dinhngochien opened this issue Jan 17, 2020 · 4 comments

Comments

@dinhngochien
Copy link

dinhngochien commented Jan 17, 2020

  • Version:
  • devise_token_auth (1.1.3)
  • angular2-token (0.2.0-beta.12)
  • Rails Stacktrace:
NoMethodError (undefined method `client' for "KOPKQBLorZFH8T0vDhje8o":String):
  
devise_token_auth (1.1.3) app/controllers/devise_token_auth/concerns/set_user_by_token.rb:89:in `update_auth_header'
activesupport (5.1.7) lib/active_support/callbacks.rb:413:in `block in make_lambda'
activesupport (5.1.7) lib/active_support/callbacks.rb:246:in `block in halting'
activesupport (5.1.7) lib/active_support/callbacks.rb:511:in `block in invoke_after'
activesupport (5.1.7) lib/active_support/callbacks.rb:511:in `each'
activesupport (5.1.7) lib/active_support/callbacks.rb:511:in `invoke_after'
activesupport (5.1.7) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.1.7) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.7) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.7) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.7) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.7) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.7) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.7) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.7) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.7) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.7) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.7) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.7) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.7) lib/action_dispatch/routing/mapper.rb:16:in `block in <class:Constraints>'
actionpack (5.1.7) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.7) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.7) lib/action_dispatch/routing/route_set.rb:844:in `call'
rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'
bullet (6.1.0) lib/bullet/rack.rb:15:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.1.1) lib/rack/etag.rb:27:in `call'
rack (2.1.1) lib/rack/conditional_get.rb:40:in `call'
rack (2.1.1) lib/rack/head.rb:14:in `call'
activerecord (5.1.7) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.7) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.7) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/executor.rb:12:in `call'
airbrake (10.0.0) lib/airbrake/rack/middleware.rb:32:in `call!'
airbrake (10.0.0) lib/airbrake/rack/middleware.rb:21:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.7) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.7) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.7) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.7) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.1.1) lib/rack/runtime.rb:24:in `call'
activesupport (5.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.7) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.1.1) lib/rack/sendfile.rb:113:in `call'
railties (5.1.7) lib/rails/engine.rb:522:in `call'
thin (1.7.2) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.7.2) lib/thin/connection.rb:84:in `catch'
thin (1.7.2) lib/thin/connection.rb:84:in `pre_process'
thin (1.7.2) lib/thin/connection.rb:53:in `process'
thin (1.7.2) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.2.7) lib/eventmachine.rb:195:in `run_machine'
eventmachine (1.2.7) lib/eventmachine.rb:195:in `run'
thin (1.7.2) lib/thin/backends/base.rb:73:in `start'
thin (1.7.2) lib/thin/server.rb:162:in `start'
rack (2.1.1) lib/rack/handler/thin.rb:24:in `run'
rack (2.1.1) lib/rack/server.rb:329:in `start'
railties (5.1.7) lib/rails/commands/server/server_command.rb:44:in `start'
railties (5.1.7) lib/rails/commands/server/server_command.rb:135:in `block in perform'
railties (5.1.7) lib/rails/commands/server/server_command.rb:130:in `tap'
railties (5.1.7) lib/rails/commands/server/server_command.rb:130:in `perform'
thor (1.0.1) lib/thor/command.rb:27:in `run'
thor (1.0.1) lib/thor/invocation.rb:127:in `invoke_command'
thor (1.0.1) lib/thor.rb:392:in `dispatch'
railties (5.1.7) lib/rails/command/base.rb:63:in `perform'
railties (5.1.7) lib/rails/command.rb:44:in `invoke'
railties (5.1.7) lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:9:in `require'

I got this error when updating the ruby version from 2.4.1 to 2.6.5(rails 5.1.7)

@CharlieIGG
Copy link

@dinhngochien can you share how you resolved this please? 🙏

@faldunate
Copy link

Does anyone know the solution?

@CharlieIGG
Copy link

@faldunate this is now working for me, but I don't remember what I did. Most likely has to do with the structure in the request... 🤔

@blackst0ne
Copy link

I had the same problem.
I had overwritten DeviseSessionsController#create action to be able to sign in using a username.

In my case the fix was just to update the part of the overwritten method:

-        # create client id
-        @client_id = SecureRandom.urlsafe_base64(nil, false)
-        @token     = SecureRandom.urlsafe_base64(nil, false)
-
-        @resource.tokens[@client_id] = {
-          token: BCrypt::Password.create(@token),
-          expiry: (Time.zone.now + ::DeviseTokenAuth.token_lifespan).to_i
-        }
+        @token = @resource.create_token

Just in case if it helps anybody.

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

4 participants