Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test? #12

Open
iainbryson opened this issue Sep 10, 2017 · 2 comments
Open

How to test? #12

iainbryson opened this issue Sep 10, 2017 · 2 comments

Comments

@iainbryson
Copy link

HI there,

I've (finally) gotten minitest of doorkeeper before_action :doorkeeper_authorize! protected controllers by creating the user/oauth_application/access_token with all the proper fields working.

When I move to before_action :authenticate_user! with devise-doorkeeper, it fails with:

Expected response to be a <2XX: success>, but was a <401: Unauthorized>
Response body: {"error":"You need to sign in or sign up before continuing."}

The same controller code with authenticate_user! works fine outside the test. Is there anything else to consider in the testing? Or an example?

Thanks in advance!

@pjmartorell
Copy link

You should use authenticate_user! or doorkeeper_authorize! but not both at the same time. Ideally you should use authenticate_user! only, but in my case (Rails API-only app) it was not working properly.

Take a look at this article as well, it may help you: https://github.com/doorkeeper-gem/doorkeeper/wiki/Running-Doorkeeper-with-Devise

@pjmartorell
Copy link

Is it working in development? I guess not. I had a problem with Devise not setting the winning_strategy. In this case, the Doorkeeper strategy is not being set as the winning strategy when the strategy fails. I solved it adding warden in my Gemfile pointing to master branch, where there is a fix for this. Check if this solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants