doorkeeper-gem / doorkeeper-devise-client

An example OAuth 2 client for Doorkeeper Provider App using Rails and Devise

Home Page:https://doorkeeper-devise-client.herokuapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

undefined local variable or method `new_user_session_path' for #<Users::OmniauthCallbacksController:0x0055f3bb2ad758>

gregijc opened this issue · comments

Dear good people..
I've been struggling to solve this issue the past few days..

System configuration

PROVIDER (I made it by myself)
according to gem list:

  1. devise (4.5.0)
  2. doorkeeper (5.0.2)
  3. rails (5.1.6)
  4. warden (1.2.7)
  5. I use Ruby 2.5.1 (ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux])

I only use gem 'doorkeeper' and 'devise' in my gemfile
provider gemfile

CLIENT (pulling from https://github.com/doorkeeper-gem/doorkeeper-devise-client)
according to gem list

  1. devise (1.5.1)
  2. oauth2 (0.5.1)
  3. rails (3.1.3)
  4. warden (1.1.0)
  5. omniauth (1.0.1)
  6. omniauth-oauth2 (1.0.0)
  7. I use Ruby 2.1.0 (ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux])

========================================================================

Steps to reproduce

So I click this 'sign in with oauth2 provider' on my doorkeeper-devise-client
client ss

and then it redirect me to
http://localhost:3000/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback
because I haven't log in to my provider yet..

Here is my provider doorkeeper.rb -> config/initializers/doorkeeper.rb
provider doorkeeper

And then after I login, it redirected me to
http://localhost:4000/users/auth/doorkeeper/callback?code=ea6096403e07e657cae1cedb28e5b72ef69783b14ee17ab56fd2102aabe4868d
with error like this
undefined local variable or method `new_user_session_path' for #Users::OmniauthCallbacksController:0x0055f3bb2ad758

the weird thing is if I use 'https://github.com/doorkeeper-gem/doorkeeper-provider-app' as my provider everything work well..

Expected behavior

I should be login to the doorkeeper-devise-client

Log

Here are the log in case you need it
PROVIDER
Started GET "/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback" for 127.0.0.1 at 2018-11-14 10:16:19 +0700
(0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"response_type"=>"code", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
Redirected to http://localhost:3000/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback
Filter chain halted as :authenticate_resource_owner! rendered or redirected
Completed 302 Found in 10ms (ActiveRecord: 0.0ms)

Started GET "/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback" for 127.0.0.1 at 2018-11-14 10:16:19 +0700
Processing by Devise::SessionsController#new as HTML
Parameters: {"return_to"=>"/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback"}
Rendering devise/sessions/new.html.erb within layouts/application
Rendered devise/shared/_links.html.erb (2.2ms)
Rendered devise/sessions/new.html.erb within layouts/application (160.3ms)
Completed 200 OK in 1312ms (Views: 1302.5ms | ActiveRecord: 0.9ms)

Started POST "/users/sign_in" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ss52g6c+ohz2P2j8+AXy8qKOEHC5QKLxbg4H+JkzXaytPfQwfVd0m7rOKgNJ3/6mJmr5Ya7RSGkcO2hg1mN69w==", "user"=>{"email"=>"email@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? ORDER BY "users"."id" ASC LIMIT ? [["email", "email@gmail.com"], ["LIMIT", 1]]
Redirected to http://localhost:3000/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback
Completed 302 Found in 359ms (ActiveRecord: 0.4ms)

Started GET "/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"response_type"=>"code", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
Doorkeeper::Application Load (0.3ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = ? LIMIT ? [["uid", "e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0"], ["LIMIT", 1]]
Doorkeeper::AccessToken Load (0.4ms) SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."application_id" = ? AND "oauth_access_tokens"."resource_owner_id" = ? AND "oauth_access_tokens"."revoked_at" IS NULL ORDER BY "oauth_access_tokens"."created_at" DESC [["application_id", 2], ["resource_owner_id", 2]]
(0.1ms) begin transaction
Doorkeeper::AccessGrant Exists (0.2ms) SELECT 1 AS one FROM "oauth_access_grants" WHERE "oauth_access_grants"."token" = ? LIMIT ? [["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["LIMIT", 1]]
SQL (0.3ms) INSERT INTO "oauth_access_grants" ("resource_owner_id", "application_id", "token", "expires_in", "redirect_uri", "created_at", "scopes") VALUES (?, ?, ?, ?, ?, ?, ?) [["resource_owner_id", 2], ["application_id", 2], ["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["expires_in", 600], ["redirect_uri", "http://localhost:4000/users/auth/doorkeeper/callback"], ["created_at", "2018-11-14 03:16:30.722657"], ["scopes", ""]]
(63.0ms) commit transaction
Redirected to http://localhost:4000/users/auth/doorkeeper/callback?code=ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc
Completed 302 Found in 103ms (ActiveRecord: 67.1ms)

Started POST "/oauth/token" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Doorkeeper::TokensController#create as /
Parameters: {"grant_type"=>"authorization_code", "code"=>"[FILTERED]", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
Doorkeeper::AccessGrant Load (0.3ms) SELECT "oauth_access_grants".* FROM "oauth_access_grants" WHERE "oauth_access_grants"."token" = ? LIMIT ? [["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["LIMIT", 1]]
Doorkeeper::Application Load (0.2ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = ? LIMIT ? [["uid", "e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0"], ["LIMIT", 1]]
(0.1ms) begin transaction
Doorkeeper::AccessGrant Load (0.2ms) SELECT "oauth_access_grants".* FROM "oauth_access_grants" WHERE "oauth_access_grants"."id" = ? LIMIT ? [["id", 64], ["LIMIT", 1]]
SQL (0.3ms) UPDATE "oauth_access_grants" SET "revoked_at" = ? WHERE "oauth_access_grants"."id" = ? [["revoked_at", "2018-11-14 03:16:30.924931"], ["id", 64]]
Doorkeeper::Application Load (0.2ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
CACHE Doorkeeper::Application Load (0.0ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
Doorkeeper::AccessToken Exists (0.2ms) SELECT 1 AS one FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = ? LIMIT ? [["token", "9ae580adf7d24244119fe7696c348a7df6f70d1dc9f2eb679e904b1dddfcbf4a"], ["LIMIT", 1]]
Doorkeeper::AccessToken Exists (0.1ms) SELECT 1 AS one FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."refresh_token" = ? LIMIT ? [["refresh_token", "b75bba568350dff1e4b5254b83d347c0cea11cbb34e196899f22d78b970b9038"], ["LIMIT", 1]]
SQL (0.2ms) INSERT INTO "oauth_access_tokens" ("resource_owner_id", "application_id", "token", "refresh_token", "expires_in", "created_at", "scopes") VALUES (?, ?, ?, ?, ?, ?, ?) [["resource_owner_id", 2], ["application_id", 2], ["token", "9ae580adf7d24244119fe7696c348a7df6f70d1dc9f2eb679e904b1dddfcbf4a"], ["refresh_token", "b75bba568350dff1e4b5254b83d347c0cea11cbb34e196899f22d78b970b9038"], ["expires_in", 7200], ["created_at", "2018-11-14 03:16:30.965406"], ["scopes", ""]]
(106.7ms) commit transaction
Completed 200 OK in 161ms

Started GET "/api/v1/me.json" for 127.0.0.1 at 2018-11-14 10:16:31 +0700

ActionController::RoutingError (No route matches [GET] "/api/v1/me.json"):

actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:63:in call' web-console (3.7.0) lib/web_console/middleware.rb:135:in call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in block in call' web-console (3.7.0) lib/web_console/middleware.rb:20:in catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in call' actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in call_app' railties (5.1.6) lib/rails/rack/logger.rb:24:in block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in block in tagged' activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in tagged' railties (5.1.6) lib/rails/rack/logger.rb:24:in call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in call' actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in call' rack (2.0.6) lib/rack/method_override.rb:22:in call'
rack (2.0.6) lib/rack/runtime.rb:22:in call' activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in call' actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in call'
rack (2.0.6) lib/rack/sendfile.rb:111:in call' railties (5.1.6) lib/rails/engine.rb:522:in call'
puma (3.12.0) lib/puma/configuration.rb:225:in call' puma (3.12.0) lib/puma/server.rb:658:in handle_request'
puma (3.12.0) lib/puma/server.rb:472:in process_client' puma (3.12.0) lib/puma/server.rb:332:in block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

CLIENT
Started GET "/users/auth/doorkeeper/callback?code=ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Users::OmniauthCallbacksController#failure as HTML
Parameters: {"code"=>"ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"}
Completed 500 Internal Server Error in 17ms

NameError (undefined local variable or method new_user_session_path' for #<Users::OmniauthCallbacksController:0x0055d5bd323258>): app/controllers/application_controller.rb:5:in new_session_path'

Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (13.7ms)

Hi @gregijc . This repo ( https://github.com/doorkeeper-gem/doorkeeper-devise-client ) is too old (last changes were made in 2011), so I don't sure it can work with last Doorkeeper versions.

Hi @gregijc . Also, did you double-check you routes ? Could you please post the output of the rake routes ?

Hi, I'm working on reviving the example app, so I'm transferring the issue to that repo.

I fixed a few low hanging fruits and I believe it's working already

I updated this repo to use latest Rails and Devise and also fixed a few minor issues. I tested against doorkeeper-provider-app locally and found no issues so far.

@gregijc please take a look, as for now, I'm closing the issue