【问题标题】:validate client id before granting access token with authentication using user credentials oauth2+doorkeeper+rails在使用用户凭据 oauth2+doorkeeper+rails 通过身份验证授予访问令牌之前验证客户端 ID
【发布时间】:2015-04-18 03:42:53
【问题描述】:

我已经使用用户名和密码实现了 oauth2 令牌请求,但我需要在身份验证之前进行 client_id 和秘密验证。如果没有 client_id 或 secret,它应该返回类似“Invalid application”的错误消息。在使用用户名和密码进行身份验证之前,有什么方法可以让 client_id 和 secret 成为必填字段。

【问题讨论】:

  • 在 doorkeeper.rb 文件中,您可以应用您的条件进行验证。
  • 您好,我已经在this answer 的另一个线程中回复了您

标签: ruby-on-rails oauth-2.0 doorkeeper


【解决方案1】:

您可以在 rb 文件顶部使用 before_save 并检查参数是否存在?

before_save :validate_stuff

def validate_stuff
  unless params[:client_id].present? && params[:secret].present?
    raise "Please enter all the info."
  end
end

每次尝试保存对象时都会触发

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-20
    • 2012-12-28
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多