oauth2-rs
oauth2-rs copied to clipboard
The returned response_body cannot be parsed.
I got the correct response_body in the process of getting the token, and I can print it out.
Here's the content of the body I returned:
{"access_token":"VnclKWprb0DoU2oAkec/G4wTS96VwUkJ/LNj8gJzXmAqr0UDiGJr0EdLJzybL0sZ******************","refresh_token":"r5B0WE7l3muwUiVRcE5drnO8+uPVW6UpL4A183lToOHAm4FDiS/Sxpv+8wIlkdooXLGp9mseM*****************","scope":"base.profile","expires_in":1***************85}
However, when executing oauth2-rs/src/lib.rs:1939, I kept prompting a parsing error. I don't think my data format or data content is wrong. I want to know why?
https://github.com/ramosbugs/oauth2-rs/blob/7c10cf07feb9538f9cc66dcb457bd36fbb1ca864/src/lib.rs#L1939
what's the Display and/or Debug output of the parsing error?
I get the following information when I run the login, with the emphasis on the last tip.
version: HTTP/1.1 method: GET scheme: Http host: Name("127.0.0.1:8888") path: /api/private/session/begin query_string: None remote_addr: 127.0.0.1:34602 hdr: x-forwarded-host="crates.XXXX.com" hdr: x-forwarded-proto="http" hdr: x-forwarded-port="80" hdr: x-forwarded-for="::ffff:10.70.218.143" hdr: x-broccoli="[object Object]" hdr: cookie="cargo_session=XXXXXXXXXXXXXXXXXXXXXgjB14=Z2l0aHViX2XXXXXXXXXXXXXXXXXXXXXXXXXWLW9qeTd2cHBxc1H/" hdr: accept-language="zh,zh-CN;q=0.9,en-US;q=0.8,en;q=0.7" hdr: accept-encoding="gzip, deflate" hdr: referer="http://crates.XXXXXXXXXXXX.com/" hdr: accept="*/*" hdr: user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" hdr: connection="close" hdr: host="127.0.0.1:8888" <- 200 <- content-type "application/json; charset=utf-8" <- content-length "261" <- set-cookie "cargo_session=6XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3N0YXRl/1XXXXXXXXXXXXXXXXXXXXXXXXXX9TNUH/; HttpOnly; SameSite=Strict; Path=/; Max-Age=7776000" at=info method=GET path="/api/private/session/begin" request_id= fwd="" service=2ms status=200 user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" version: HTTP/1.1 method: GET scheme: Http host: Name("127.0.0.1:8888") path: /api/private/session/authorize query_string: Some("code=P/JL7XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXaVFxE+JXICJhREIQ==&state=XdvXXXXXXXXXXXXOCoS5A") remote_addr: 127.0.0.1:34604 hdr: x-forwarded-host="crates.XXXXXXXXXXX.com" hdr: x-forwarded-proto="http" hdr: x-forwarded-port="80" hdr: x-forwarded-for="::ffff:10.70.218.143" hdr: x-broccoli="[object Object]" hdr: cookie="cargo_session=6tQZVXXXXXXXXXXXXXXXXXXXXfmP8=Z2l0aHViX29XXXXXXXXXXXXXXXXXXXXXXXXXXXZZENtRTZPQ29TNUH/" hdr: accept-language="zh,zh-CN;q=0.9,en-US;q=0.8,en;q=0.7" hdr: accept-encoding="gzip, deflate" hdr: referer="http://crates.XXXXXXXXXXXX.com/" hdr: accept="*/*" hdr: user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" hdr: connection="close" hdr: host="127.0.0.1:8888" <- 500 <- content-type "application/json; charset=utf-8" <- content-length "47" at=info method=GET path="/api/private/session/authorize?code=P/JXXXXXXXXXXXXXXXXXXXXXXXxv9ZLRK1y+DT6XXXXXXXXXXXXXXXXXXX+JXICJhREIQ==&state=XdXXXXXXXXXXXXXXXX6OCoS5A" request_id= fwd="" service=223ms status=500 user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" cause="Failed to parse server response"
please take a look at https://github.com/ramosbugs/openidconnect-rs/issues/34 (different crate, but same issue and suggestions). both crates expose a cause chain that can be walked to see the full diagnostic messages.
I don't know if my understanding is correct, but I see your suggestion is to further identify where the error occurred, and I'm working on that. Thank you for your reply. I wonder if the returned response should be JSON text. Will some of the responses be encoded and some of the responses are not encoded?