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

ureq http_client doesn't work with microsoft (tested for devicecode flow) #182

Closed
nerditation opened this issue Sep 8, 2022 · 1 comment

Comments

@nerditation
Copy link
Contributor

I was trying to authenticate using microsoft devicecode flow, as documented here, but the server returned 404. but I got a totally normal response when I directly post the authentication data to the endpoint using ureq::Request::send_form(...)

so I checked the logs and found that there were different http headers: the failed on has a Transfer-Encoding: chunked header, while the good one contains a Content-Length: 12345678 header.

I don't know whether microsoft's implementation is correct, or what the oauth standard says, but I found the reason leading to this difference is oauth2::ureq::http_client calls send(reader) on the ureq::Request object:

req.send(&*request.body)

but we could instead (and should) call send_bytes(byte_slice) since the body is already serialized data (urlencoded form), why add another indirection to wrap it into a reader?

    req.send_bytes(&request.body)

this not only feels more nature, it also fixes the compatibility issue with microsoft since payload with type of slice makes ureq automatically add a Content-Length header.

@ramosbugs
Copy link
Owner

Sounds like a good fix. Please feel free to submit a PR!

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