加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-4 – 设计activeadmin门卫 – 过滤链停止为:requ

发布时间:2020-12-17 03:33:08 所属栏目:百科 来源:网络整理
导读:我无法为在/ oauth / applications中创建的应用程序生成访问令牌 我在门卫初始化文件中做了以下更改 doorkeeper.rb resource_owner_authenticator do User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url) end 当我尝试从/ oauth / app
我无法为在/ oauth / applications中创建的应用程序生成访问令牌

我在门卫初始化文件中做了以下更改

doorkeeper.rb

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

当我尝试从/ oauth / applications授权应用程序时,我收到以下错误

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)

我想生成身份验证令牌,以授权应用程序使用api调用我的应用程序

试图在Doorkeeper关注railscast剧集

这是我的application

解决方法

resource_owner_authenticator应替换为下面的块,以便为您的客户端应用程序生成auth tockns

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读