Skip to content

Allow client_credentials flow #13

Description

@szechyjs

When authenticating using client_credentials flow resource_owner_id is nil. This results in the following exception.

ActiveRecord::RecordNotFound (Couldn't find User without an ID):

activerecord (5.2.1) lib/active_record/relation/finder_methods.rb:429:in `find_with_ids'
activerecord (5.2.1) lib/active_record/relation/finder_methods.rb:69:in `find'
activerecord (5.2.1) lib/active_record/querying.rb:5:in `find'
activerecord (5.2.1) lib/active_record/core.rb:167:in `find'
devise-doorkeeper (1.1.2) lib/devise/strategies/doorkeeper.rb:48:in `resource_from_token'
devise-doorkeeper (1.1.2) lib/devise/strategies/doorkeeper.rb:17:in `authenticate!'
warden (1.2.7) lib/warden/strategies/base.rb:54:in `_run!'
warden (1.2.7) lib/warden/proxy.rb:359:in `block in _run_strategies_for'
warden (1.2.7) lib/warden/proxy.rb:354:in `each'
warden (1.2.7) lib/warden/proxy.rb:354:in `_run_strategies_for'
warden (1.2.7) lib/warden/proxy.rb:324:in `_perform_authentication'
warden (1.2.7) lib/warden/proxy.rb:128:in `authenticate!'
devise (4.5.0) lib/devise/controllers/helpers.rb:118:in `authenticate_user!'

https://github.com/betterup/devise-doorkeeper/blob/master/lib/devise/strategies/doorkeeper.rb#L48

Edit: even if I don't use authenticate_user on a controller ActiveRecord::RecordNotFound (Couldn't find User without an ID) is thrown when using client_credentials. The only way around it is to remove :doorkeeper from the devise config in the User model.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions