Skip to content

httr2 (development version)

httr2 1.0.6

CRAN release: 2024-11-04

httr2 1.0.5

CRAN release: 2024-09-26

httr2 1.0.4

CRAN release: 2024-09-13

httr2 1.0.3

CRAN release: 2024-08-22

httr2 1.0.2

CRAN release: 2024-07-16

httr2 1.0.1

CRAN release: 2024-04-01

httr2 1.0.0

CRAN release: 2023-11-14

Function lifecycle

Multiple requests

OAuth features

  • A new vignette("oauth") gives many more details about how OAuth works and how to use it with httr2 (#234), and the OAuth docs have been overhauled to make it more clear that you should use req_oauth_*(), not oauth_*() (#330).

  • If you are using an OAuth token with a refresh token, and that refresh token has expired, then httr2 will now re-run the entire flow to get you a new token (#349).

  • New oauth_cache_path() returns the path that httr2 uses for caching OAuth tokens. Additionally, you can now change the cache location by setting the HTTR2_OAUTH_CACHE env var. This is now more obvious to the user, because httr2 now informs the user whenever a token is cached.

  • oauth_flow_auth_code() gains a redirect_uri argument rather than deriving this URL automatically from the host_name and port (#248). It uses this argument to automatically choose which strategy to use to get the auth code, either launching a temporary web server or, new, allowing you to manually enter the details with the help of a custom JS/HTML page hosted elsewhere, or by copying and pasting the URL you’re redirected to (@fh-mthomson, #326). The temporary web server now also respects the path component of redirect_uri, if the API needs a specific path (#149).

  • New oauth_token_cached() allows you to get an OAuth token while still taking advantage of httr2’s caching and auto-renewal features. For expert use only (#328).

Other new features

Minor improvements and bug fixes

  • The httr2 examples now only run on R 4.2 and later so that we can use the base pipe and lambda syntax (#345).

  • OAuth errors containing a url now correctly display that URL (instead of the string “uri”).

  • curl_translate() now uses the base pipe, and produces escapes with single quotes or raw strings in case double quotes can’t be used (@mgirlich, #264). It gains the argument simplify_headers that removes some common but unimportant headers, like Sec-Fetch-Dest or sec-ch-ua-mobile (@mgirlich, #256). It also parses the query components of the url (@mgirlich, #259) and works with multiline commands from the clipboard (@mgirlich, #254).

  • local_mocked_responses() and with_mocked_responses() now accept a list of responses which will be returned in sequence. They also now correctly trigger errors when the mocked response represents an HTTP failure (#252).

  • oauth_flow_refresh() now only warns, not errors, if the refresh_token changes, making it a little easier to use in manual workflows (#186).

  • obfuscated() values now display their original call when printed.

  • req_body_json() gains custom content type argument and respects custom content-type set in header (@mgirlich, #189).

  • req_cache() now combine the headers of the new response with the headers of the cached response. In particular, this fixes resp_body_json/xml/html() on cached responses (@mgirlich, #277).

  • req_perform() now throws error with class httr2_failure/httr2_error if the request fails, and that error now captures the curl error as the parent. If the request succeeds, but the response is an HTTP error, that error now also has super class httr2_error. This means that all errors thrown by httr2 now inherit from the httr2_error class. See new docs in ?req_error() for more details.

  • req_perform()’s progress bar can be suppressed by setting options(httr2_progress = FALSE) (#251). Progress bars displayed while waiting for some time to pass now tell you why they’re waiting (#206).

  • req_oauth_bearer_jwt() now includes the claim in the cache key (#192).

  • req_oauth_device() now takes a auth_url parameter making it usable (#331, @taerwin).

  • req_url_query() gains a .multi parameter that controls what happens when you supply multiple values in a vector. The default will continue to error but you can use .multi = "comma" to separate with commas, "pipe" to separate with |, and "explode" to generate one parameter for each value (e.g. ?a=1&a=2) (#350).

httr2 0.2.3

CRAN release: 2023-05-08

httr2 0.2.2

CRAN release: 2022-09-25

httr2 0.2.1

CRAN release: 2022-05-10

  • “Wrapping APIs” is now an article, not a vignette.

  • req_template() now appends the path instead of replacing it (@jchrom, #133)

httr2 0.2.0

CRAN release: 2022-04-28

New features

Minor improvements and bug fixes

httr2 0.1.1

CRAN release: 2021-09-28

  • Fix R CMD check failures on CRAN

  • Added a NEWS.md file to track changes to the package.