Skip to content

fix(auth): percent-encode OAuth 1.0a parameters per RFC 5849 - #115

Open
wadefletch wants to merge 1 commit into
xdevplatform:mainfrom
wadefletch:wade/oauth1-percent-encoding
Open

wadefletch wants to merge 1 commit into
xdevplatform:mainfrom
wadefletch:wade/oauth1-percent-encoding

Conversation

@wadefletch

Copy link
Copy Markdown

With --auth oauth1, any request whose query contains a space fails with a bare 401, including every multi-word xurl search. encode() uses url.QueryEscape, which writes a space as +, but RFC 5849 §3.6 requires %20, so xurl signs a different base string than X computes.

Separately, X rejects a signed request whose query carries a raw reserved character, such as query=from:XDevelopers or start_time=2026-11-20T00:00:00Z, even when the signature is correct. xurl now sends the query in the same encoding it signs.

encode() used url.QueryEscape, which writes a space as + instead of %20,
so every OAuth 1.0a request whose query contained a space, such as a
multi-word search, was signed over a different base string than X
computes and failed with 401.

X also rejects a signed request whose query carries a raw reserved
character, such as the colon in query=from:XDevelopers, so send the
query in the same encoding the signature covers.

Amp-Thread-ID: https://ampcode.com/threads/T-7e242faa-c06f-4a65-a920-3fcacb7f8810
Co-authored-by: Wade Fletcher <wade@tractorbeam.ai>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Successfully merging this pull request may close these issues.

3 participants