2017-01-12 5 views
2

내가/OAuth를/응용 프로그램에서 만든 응용 프로그램에 대한 액세스 토큰을 생성 할 수 없습니다입니다고안 + ActiveAdmin을 + 문지기 필터 체인으로 중단 : 내가 문지기 초기화 파일의 변경 다음 수행 한</p> <p>렌더링 또는 재 require_no_authentication

doorkeeper.rb

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

나는 다음과 같은 오류가/OAuth를/응용 프로그램에서 응용 프로그램을 인증하려고

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 "https://stackoverflow.com/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) 

내가 내 응용 프로그램에 대한

Doorkeeper

에 railscast 에피소드를 따르도록 노력 API 호출을 사용하는 응용 프로그램을 인증하는 인증 토큰을 생성 할 그리고 이것은 내 application

답변

3

resource_owner_authenticator입니다해야 아래 블록으로 대체하여 클라이언트 앱에 대한 인증 요청을 생성하십시오.

resource_owner_authenticator do |routes| 
current_user || warden.authenticate!(:scope => :user) 
end 
+0

이것이 효과가 있습니다. 여기에 무슨 일이 일어나고 있는지 한두 줄을 포함시킬 수 있습니까? devise의 current_user 메소드가'User.find_by_id session [: user_id]'를 어떻게 대체하는지 알게되었습니다. – MCB