You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
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 aContent-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
callssend(reader)
on theureq::Request
object:oauth2-rs/src/ureq.rs
Line 55 in 93452e5
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?this not only feels more nature, it also fixes the compatibility issue with microsoft since payload with type of
slice
makes ureq automatically add aContent-Length
header.The text was updated successfully, but these errors were encountered: