Question

I'm trying to use a Doorkeeper gem to protect my API.

My code looks like this:

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

Here are commands I'm using to connect to my API:

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

... and ...

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

Which works fine but my problem is, that the returned Token object has an empty resource_owner_id param (this column is not being populated in the DB on token creation). Have you any idea what am i doing wrong? I've been following those tutorials:

Was it helpful?

Solution

The client credentials flow "is not associated with a resource owner" (https://github.com/applicake/doorkeeper/wiki/Client-Credentials-flow), so I think it is right that the resource_owner_id is not set.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top