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

Authorization error response is not valid JSON when api_only #1121

Closed
f3ndot opened this issue Jul 13, 2018 · 0 comments
Closed

Authorization error response is not valid JSON when api_only #1121

f3ndot opened this issue Jul 13, 2018 · 0 comments

Comments

@f3ndot
Copy link
Contributor

f3ndot commented Jul 13, 2018

Steps to reproduce

  1. Use Doorkeeper's master (presently v5.0.0.rc1)
  2. Set initializer to use api_only
  3. Make a GET request to /oauth/authorize?client_id=badclient

Expected behavior

Response should be something like

{
  "error": "The authorization server does not support this response type.",
  // potentially more metadata:
  "error_type": "unsupported_response_type",
  "status": 401
}

Actual behavior

We get just raw text back, despite the response header Content-Type: application/json:

The authorization server does not support this response type.

screen shot 2018-07-13 at 12 41 13 pm

Here is a well-formed JSON response from a successful request:

screen shot 2018-07-13 at 12 40 41 pm

The issue appears to be

def render_error
if Doorkeeper.configuration.api_only
render json: pre_auth.error_response.body[:error_description],
status: :bad_request
else
render :error
end
end
where there is no root key or JSON object established. Just a string.

Proposed solution

Prefix the error with a error key. Not sure if there is already an existing pattern elsewhere. If so, we should adopt that pattern.

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

1 participant