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

undefined method `match' for nil:NilClass #39

Closed
krunal opened this issue Oct 1, 2014 · 9 comments
Closed

undefined method `match' for nil:NilClass #39

krunal opened this issue Oct 1, 2014 · 9 comments

Comments

@krunal
Copy link

krunal commented Oct 1, 2014

Getting below error while trying to integrate with facebook or linkedin.

Backtrace

Started GET "/auth/linkedin" for 127.0.0.1 at 2014-09-30 20:59:55 -0500
ActiveRecord::SchemaMigration Load (0.1ms) SELECT schema_migrations.* FROM schema_migrations

Started GET "/omniauth/linkedin?resource_class=User" for 127.0.0.1 at 2014-09-30 20:59:55 -0500
I, [2014-09-30T20:59:55.874961 #26214] INFO -- omniauth: (linkedin) Request phase initiated.

Started GET "/omniauth/linkedin/callback?resource_class=User&oauth_token=75--c7c0dd37-c720-425f-acac-f1218cbad003&oauth_verifier=93853" for 127.0.0.1 at 2014-09-30 21:00:17 -0500
I, [2014-09-30T21:00:17.880395 #26214] INFO -- omniauth: (linkedin) Callback phase initiated.
Processing by DeviseTokenAuth::AuthController#omniauth_success as HTML
Parameters: {"resource_class"=>"User", "oauth_token"=>"75--c7c0dd37-c720-425f-acac-f1218cbad003", "oauth_verifier"=>"93853", "provider"=>"linkedin"}
User Load (0.2ms) SELECT users.* FROM users WHERE users.uid = '2UgVGWV5v_' AND users.provider = 'linkedin' ORDER BY users.id ASC LIMIT 1
Completed 500 Internal Server Error in 49ms

NoMethodError (undefined method match' for nil:NilClass): devise_token_auth (0.1.28.beta6) app/controllers/devise_token_auth/auth_controller.rb:128:ingenerate_url'
devise_token_auth (0.1.28.beta6) app/controllers/devise_token_auth/auth_controller.rb:36:in omniauth_success' actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in process_action' actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.1.6) lib/active_support/callbacks.rb:113:incall'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:215:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:215:inblock in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:149:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:149:inblock in halting_and_conditional'
activesupport (4.1.6) lib/active_support/callbacks.rb:86:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:86:inrun_callbacks'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.1.6) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.1.6) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.1.6) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.1.6) lib/abstract_controller/base.rb:136:inprocess'
actionview (4.1.6) lib/action_view/rendering.rb:30:in process' actionpack (4.1.6) lib/action_controller/metal.rb:196:indispatch'
actionpack (4.1.6) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.1.6) lib/action_controller/metal.rb:232:inblock in action'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:in call' actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:82:indispatch'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:50:in call' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:73:inblock in call'
actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.1.6) lib/action_dispatch/journey/router.rb:59:incall'
actionpack (4.1.6) lib/action_dispatch/routing/route_set.rb:678:in call' omniauth (1.2.2) lib/omniauth/strategy.rb:404:incall_app!'
omniauth (1.2.2) lib/omniauth/strategy.rb:362:in callback_phase' omniauth-oauth (1.0.1) lib/omniauth/strategies/oauth.rb:58:incallback_phase'
omniauth (1.2.2) lib/omniauth/strategy.rb:227:in callback_call' omniauth (1.2.2) lib/omniauth/strategy.rb:184:incall!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:incall!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:incall!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/builder.rb:59:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' rack (1.5.2) lib/rack/etag.rb:23:incall'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/params_parser.rb:27:in call' actionpack (4.1.6) lib/action_dispatch/middleware/flash.rb:254:incall'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/cookies.rb:560:in call' activerecord (4.1.6) lib/active_record/query_cache.rb:36:incall'
activerecord (4.1.6) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in call' activerecord (4.1.6) lib/active_record/migration.rb:380:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:29:in block in call' activesupport (4.1.6) lib/active_support/callbacks.rb:82:inrun_callbacks'
actionpack (4.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:73:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.1.6) lib/rails/rack/logger.rb:38:incall_app'
railties (4.1.6) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:inblock in tagged'
activesupport (4.1.6) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.1.6) lib/active_support/tagged_logging.rb:68:intagged'
railties (4.1.6) lib/rails/rack/logger.rb:20:in call' actionpack (4.1.6) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
actionpack (4.1.6) lib/action_dispatch/middleware/static.rb:64:in call' rack (1.5.2) lib/rack/sendfile.rb:112:incall'
railties (4.1.6) lib/rails/engine.rb:514:in call' railties (4.1.6) lib/rails/application.rb:144:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:incall'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /home/krunal/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice'
/home/krunal/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /home/krunal/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

@lynndylanhurley
Copy link
Owner

@krunal - can you try upgrading to the latest beta? Version 0.1.29.beta5 may solve the issue.

@krunal
Copy link
Author

krunal commented Oct 1, 2014

Getting same error with version 0.1.29.beta5.

@lynndylanhurley
Copy link
Owner

@krunal - one of the files from the stacktrace (app/controllers/devise_token_auth/auth_controller.rb:128) doesn't exist in the latest version. Can you please post a recent stacktrace from after the upgrade? I just want to make sure that it's the same issue.

@krunal
Copy link
Author

krunal commented Oct 1, 2014

Started GET "/auth/linkedin/callback" for 127.0.0.1 at 2014-10-01 16:55:52 -0500
Processing by DeviseTokenAuth::OmniauthCallbacksController#omniauth_success as HTML
Parameters: {"provider"=>"linkedin"}
User Load (0.8ms) SELECT users.* FROM users WHERE users.uid = '2UgVGWV5v_' AND users.provider = 'linkedin' ORDER BY users.id ASC LIMIT 1
Completed 500 Internal Server Error in 164ms

NoMethodError (undefined method match' for nil:NilClass): devise_token_auth (0.1.29.beta5) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:141:ingenerate_url'
devise_token_auth (0.1.29.beta5) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:29:in omniauth_success' actionpack (4.1.6) lib/action_controller/metal/implicit_render.rb:4:insend_action'
actionpack (4.1.6) lib/abstract_controller/base.rb:189:in process_action' actionpack (4.1.6) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.1.6) lib/active_support/callbacks.rb:113:incall'
activesupport (4.1.6) lib/active_support/callbacks.rb:113:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:229:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:229:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:166:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:166:inblock in halting'
activesupport (4.1.6) lib/active_support/callbacks.rb:86:in call' activesupport (4.1.6) lib/active_support/callbacks.rb:86:inrun_callbacks'
actionpack (4.1.6) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.1.6) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.1.6) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.1.6) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.1.6) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.1.6) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.1.6) lib/action_controller/metal/params_wrapper.rb:250:inprocess_action'
activerecord (4.1.6) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.1.6) lib/abstract_controller/base.rb:136:inprocess'
actionview (4.1.6) lib/action_view/rendering.rb:30:in `process'

@lynndylanhurley
Copy link
Owner

Thanks @krunal, I'll take a look ASAP.

@lynndylanhurley
Copy link
Owner

@krunal - I'm having trouble reproducing this issue, but it looks like the client is failing to append the auth_origin_url to the OAuth request (relevant code here). The server is trying to parse the URL, but is failing because the URL is nil.

Here is an example of a successful request. Note the auth_origin_url param.

Started GET "/auth/github?auth_origin_url=http%3A%2F%2Fng-token-auth.dev%2F" for 127.0.0.1 at 2014-10-02 11:38:57 -0500

This is your failing request. There is no auth_origin_url present.

Started GET "/auth/linkedin" for 127.0.0.1 at 2014-09-30 20:59:55 -0500

Can you think of a reason why this value would be missing? ng-token-auth automatically appends the param so it shouldn't be an issue with normal use.

@krunal
Copy link
Author

krunal commented Oct 6, 2014

I was hitting the url through browser instead of angularjs. I think thats the problem.

@lynndylanhurley
Copy link
Owner

Cool - I should probably make a note in the readme about this. Thanks @krunal!

@phs1919
Copy link

phs1919 commented Mar 3, 2015

I am having the same issue but I am not using angularjs. The following is my backtrace:

NoMethodError in DeviseTokenAuth::OmniauthCallbacksController#omniauth_success
undefined method `match' for nil:NilClass

Extracted source (around line #158):

      # ensure that hash-bang is present BEFORE querystring for angularjs
      unless url.match(/#/)
        auth_url += '#'
      end

devise_token_auth (0.1.32.beta5) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:158:in generate_url' devise_token_auth (0.1.32.beta5) app/controllers/devise_token_auth/omniauth_callbacks_controller.rb:33:inomniauth_success'
actionpack (4.2.0) lib/abstract_controller/base.rb:198:in process_action' actionpack (4.2.0) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:20:in block in process_action' activesupport (4.2.0) lib/active_support/callbacks.rb:117:incall'
activesupport (4.2.0) lib/active_support/callbacks.rb:117:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:169:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:169:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:169:inblock in halting'
activesupport (4.2.0) lib/active_support/callbacks.rb:92:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:92:in_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_process_action_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.0) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.2.0) lib/active_support/notifications.rb:164:inblock in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.2.0) lib/active_support/notifications.rb:164:ininstrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in process_action' activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in process' actionview (4.2.0) lib/action_view/rendering.rb:30:inprocess'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in dispatch' actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:indispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in block in action' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:incall'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in dispatch' actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:inserve'
actionpack (4.2.0) lib/action_dispatch/routing/mapper.rb:49:in serve' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:inblock in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in each' actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:inserve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:incall!'
omniauth (1.2.2) lib/omniauth/strategy.rb:164:in call' omniauth (1.2.2) lib/omniauth/builder.rb:59:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in call' rack (1.6.0) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:incall'
rack (1.6.0) lib/rack/methodoverride.rb:22:in call' rack (1.6.0) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.6.0) lib/rack/session/abstract/id.rb:220:in call' warden (1.2.3) lib/warden/manager.rb:35:inblock in call'
warden (1.2.3) lib/warden/manager.rb:34:in catch' warden (1.2.3) lib/warden/manager.rb:34:incall'
rack (1.6.0) lib/rack/etag.rb:24:in call' rack (1.6.0) lib/rack/conditionalget.rb:25:incall'
rack (1.6.0) lib/rack/head.rb:13:in call' actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:incall'
activerecord (4.2.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:incall'
activerecord (4.2.0) lib/active_record/migration.rb:378:in call' actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.2.0) lib/active_support/callbacks.rb:88:in call' activesupport (4.2.0) lib/active_support/callbacks.rb:88:in_run_callbacks'
activesupport (4.2.0) lib/active_support/callbacks.rb:734:in _run_call_callbacks' activesupport (4.2.0) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in call' actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.2.0) lib/rails/rack/logger.rb:38:incall_app'
railties (4.2.0) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:inblock in tagged'
activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:intagged'
railties (4.2.0) lib/rails/rack/logger.rb:20:in call' actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.6.0) lib/rack/runtime.rb:18:in call' activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:incall'
rack (1.6.0) lib/rack/lock.rb:17:in call' actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:incall'
railties (4.2.0) lib/rails/engine.rb:518:in call' railties (4.2.0) lib/rails/application.rb:164:incall'
rack (1.6.0) lib/rack/lock.rb:17:in call' rack (1.6.0) lib/rack/content_length.rb:15:incall'
rack (1.6.0) lib/rack/handler/webrick.rb:89:in service' /Users/richardpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:138:inservice'
/Users/richardpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/httpserver.rb:94:in run' /Users/richardpark/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/webrick/server.rb:294:inblock in start_thread'

I am using the following gems:

gem 'rails', '4.2'
gem 'rails-api', '~> 0.4.0'
gem 'spring', :group => :development
gem 'sqlite3'
gem 'devise_token_auth', '~> 0.1.31'

# OmniAuth authentication provider gems
gem 'omniauth-facebook', '~> 2.0.1'
gem 'omniauth-twitter', '~> 1.1.0'

I would really appreciate any help! Thanks :)

shaggyone added a commit to shaggyone/devise_token_auth that referenced this issue Mar 16, 2015
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

3 participants