【问题标题】:resource_owner_id not being populatedresource_owner_id 未填充
【发布时间】:2013-12-07 17:51:04
【问题描述】:

我正在尝试使用 Doorkeeper gem 来保护我的 API。

我的代码如下所示:

initializers/doorkeeper.rb

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

  default_scopes :public # if no scope was requested, this will be the default
  optional_scopes :admin, :write

  enable_application_owner :confirmation => false
end

以下是我用来连接我的 API 的命令:

RestClient.post 'http://localhost:3000/oauth/token', {
  grant_type: 'client_credentials',
  client_id: '26b8e5c92367d703ad35a2fc16b14dc93327a15798068ccba473aa2e3d897883',
  client_secret: 'b16079915cdc20b5373f1601e31cece5a84274f772cfd89aec12c90fd110775e'
}

...和...

RestClient.get 'http://localhost:3000/api/v1/videos', { 'Authorization' => 'Bearer <token_from_previous_request>' }

这很好用,但我的问题是,返回的 Token 对象有一个空的 resource_owner_id 参数(在创建令牌时,此列未填充到数据库中)。你知道我在做什么错吗?我一直在关注这些教程:

【问题讨论】:

    标签: ruby-on-rails ruby oauth doorkeeper


    【解决方案1】:

    客户端凭据流“与资源所有者无关”(https://github.com/applicake/doorkeeper/wiki/Client-Credentials-flow),因此我认为未设置 resource_owner_id 是正确的。

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2016-07-11
      • 2012-03-28
      • 2020-02-21
      • 2015-02-23
      • 2019-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多