Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise+activeadmin+doorkeeper - Filter chain halted as :require_no_authentication rendered or redirected

I am not able to generate access token for applications created in /oauth/applications

i have done following changes in the doorkeeper initializer file

doorkeeper.rb

resource_owner_authenticator do
    User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
  end

when i try to authorize an app from /oauth/applications i get the following error

Started GET "/oauth/authorize?client_id=87122ba040e56b44477a69b189ad809bf663c374f8cc513dd55bff81c07f030b&redirect_uri=http%3A%2F%2Flocalhost%3A3001%2Fauth%2Fapi_provider%2Fcallback&response_type=code&scope=" for 127.0.0.1 at 2017-01-12 12:04:52 +0530
Processing by Doorkeeper::AuthorizationsController#new as HTML
  Parameters: {"client_id"=>"87122ba040e56b44477a69b189ad809bf663c374f8cc513dd55bff81c07f030b", "redirect_uri"=>"http://localhost:3001/auth/api_provider/callback", "response_type"=>"code", "scope"=>""}
  User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1
Redirected to http://localhost:3000/users/sign_in
Filter chain halted as :authenticate_resource_owner! rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.3ms)


Started GET "/users/sign_in" for 127.0.0.1 at 2017-01-12 12:04:52 +0530
Processing by Devise::SessionsController#new as HTML
  User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 2ms (ActiveRecord: 0.1ms)


Started GET "/" for 127.0.0.1 at 2017-01-12 12:04:52 +0530
Processing by PagesController#index as HTML
  Rendered pages/index.html.erb within layouts/application (0.0ms)
  User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
  Rendered layouts/_navbar.html.erb (1.2ms)
Completed 200 OK in 136ms (Views: 135.0ms | ActiveRecord: 0.1ms)

i want to generate authentication token to authorize the apps to use api calls for my application

tried to follow railscast episode on Doorkeeper

And this is my application

like image 841
shubhangi singh Avatar asked Jan 12 '17 06:01

shubhangi singh


1 Answers

The resource_owner_authenticator should be replaced by below block to generate auth tockns for your client apps

resource_owner_authenticator do |routes|
 current_user || warden.authenticate!(:scope => :user)
end
like image 196
shubhangi singh Avatar answered Oct 22 '22 22:10

shubhangi singh