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

Handle status code 401 and content type application/x-www-form-urlencoded #169

Open
marciovmartins opened this issue Nov 2, 2024 · 2 comments

Comments

@marciovmartins
Copy link

marciovmartins commented Nov 2, 2024

Status code 401

When is returned a 401 status code with content type application/prs.hal-forms+json and proper payload, the HAL Explorer will not display the Links and HAL-FORMS Template Elements sections on the left.
There is already an Issue related to OIDC, I guess with redirects. My proposal is in the direction that if the api returns an proper HAL-FORMS template, that this would be properly rendered.

Content Type application/x-www-form-urlencoded

The HTTP Request Input form could render properly the "Body" with the Content Type application/x-www-form-urlencoded. Currently, it is always rendered as json and should be rendered as an url encoded string.

The expected result in the Body textarea would be:

client_id=api&client_secret=abc123&username=foo&password=bar&grant_type=password

Sample Project

Here is a sample project reproducing the issues.

@toedter
Copy link
Owner

toedter commented Nov 7, 2024

Thx, I'll take a look at it.

One question though: 401 (not authorized) will usually not return a payload, since you are not authorized.

@marciovmartins
Copy link
Author

I see your point and agree with you, usually will not return a payload. Thanks for bringing this up.

Though, I could not find in the RFC forbidding it. https://www.rfc-editor.org/rfc/rfc7235#section-3.1

The server could provide a "_templates" instructing the client how/where to login or where to register as a new user.
I guess would be the same behaviour of application which redirect users to the login page.

Having that in HAL-Explorer would be great to keep APIs consistent too. The person would not need to get out of HAL-Explorer to do the authentication. The only thing would be required is copy the access token and copy as a header authorization. This if HAL-Explorer does not support and do automatically for the user.
Now I need to go to some script and do a request to Keycloak, copy the access token from there and past in HAL-Explorer.

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