我正在尝试使用Doorkeeper来保护我的API。
我的代码如下所示:
初始化器/门键.
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>' }它工作得很好,但我的问题是返回的令牌对象有一个空的resource_owner_id param (这个列没有在令牌创建的DB中填充)。你知道我做错了什么吗?我一直在学习这些教程:
发布于 2014-02-27 00:22:39
客户端凭据流“不与资源所有者(https://github.com/applicake/doorkeeper/wiki/Client-Credentials-flow)相关联”,因此我认为没有设置resource_owner_id是正确的。
https://stackoverflow.com/questions/20151815
复制相似问题