Specify authentication type

UPDATE: I think I can close this based on the fact I'm using a proxy here, and wasn't aware this got split out from httr to httr2 in this way: Use a proxy for a request — req_proxy • httr2

I think I can close as self-solved, but will wait a bit and see if anyone has any comments.

This question has been asked in some other forms here, but not answered, specifically:

I want to use httr2 rather than httr now, but need to the equivalent of the following digest authentication in httr2. Please advise.

        httr::authenticate(my_user, my_password, 
            type = "digest"), httr::add_headers(my_headers), 
        body = my_request_body)

Hi @MattP,

your links provide the answer.
Use the code snippet from NTLM authentication in httr2 - #2 by jsmfws
and set httpauth = 2L. For a listing of the methods from httr you can look at httr/R/authenticate.r at main · r-lib/httr · GitHub.

So keeping @jsmfws style it would be something like

req_auth_digest <- function(req) {
  httr2::req_options(req, httpauth = 2L, userpwd = "username:password")

Yep, thanks, reading more carefully that answer, I am seeing it now.

Fyi ... check_request() isn't exported from {httr2} with my version, but assume it is ok here to use :::

    httr2::request("http://example.com") |>
error=function(e) print(glue::glue("{e}")))
#> Error: 'check_request' is not an exported object from 'namespace:httr2'

httr2::request("http://example.com") |>

Created on 2024-04-19 with reprex v2.1.0

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.