Logging in via LibreWolf results in parse error in the OAuth callback
Description
Connecting via ncspot, which uses librespot as client library, completing the login flow in LibreWolf fails with the following error: Failed to parse redirect URI from HTTP request.
There is an issue with the data LibreWolf sends back through the socket and how librespot handles it.
Version
librespot 0.8.0
How to reproduce
- Start
ncspotin terminal - Open login link in LibreWolf
- Log in and allow app
- See:
Failed to parse redirect URI from HTTP requestin terminal
Debug
I've added some debug code in fn get_authcode_listener in oauth/src/lib.rs that prints out all of the incoming request lines. Output:
request line: ""
request line: "GET /login?code={code} HTTP/1.1\r\n"There is an empty line before the actual GET request. Librespot parses the first line and fails because it is empty:
let redirect_url = request_line
.split_whitespace()
.nth(1)
.ok_or(OAuthError::AuthCodeListenerParse)?;As an extra test, I've made a local patch that basically just skips empty request lines, and the OAuth flow then succeeds in LibreWolf (starting from ncspot).
Using vanilla Firefox (149.0.2), the redirect OAuth flow works normally. Meaning that there is no empty line being sent. There is probably some (default) configuration in LibreWolf that causes this behavior. I don't know what or why but I'm wondering if librespot should handle the callback information in a more robust manner.
Host (what you are running librespot on):
- OS: Fedora 43
- Platform: x86_64
Additional context
- Ncspot 1.3.3
- Librewolf 149.0.2-2
- Vanilla Firefox 149.0.2 works correctly on the same machine with the same
ncspotandlibrespotsetup
Source: librespot-org/librespot