r-lib / httr

httr: a friendly http package for R
https://httr.r-lib.org
Other
986 stars 1.99k forks source link

OAuth callback url is encoded while it shouldn't. #732

Closed llrs closed 1 year ago

llrs commented 1 year ago

This is equivalent of the issue at httr2 but for oauth 1.0. The Twitter API expect an exact match without decoding the callback url.

The API expects a literal url such as "http://127.0.0.1:1410/" but init_oauth1.0, via oauth_header and oauth_encode encodes the url to "http%3A%2F%2F127.0.0.1%3A1410%2F" (which is not allowed in the Twitter developer page as callback url.

withr::local_envvar("HTTR_SERVER" = "127.0.0.1")
oauth_header(oauth_callback())

Is there a way to prevent this url to be encoded? All the other arguments should be encoded but this one not always apparently.

It was initially reported by a user in rtweet: https://github.com/ropensci/rtweet/issues/744, so I don't know what changed since it was added in rtweet and till it was reported. As the changes surrounding that code seem quite old.