It's not obvious how to turn authentication off after using it, so I recommend using custom handles with authentication.

authenticate(user, password, type = "basic")

Arguments

user

user name

password

password

type

type of HTTP authentication. Should be one of the following types supported by Curl: basic, digest, digest_ie, gssnegotiate, ntlm, any. It defaults to "basic", the most common type.

See also

Examples

GET("http://httpbin.org/basic-auth/user/passwd")
#> Response [http://httpbin.org/basic-auth/user/passwd] #> Date: 2020-08-17 22:22 #> Status: 401 #> Content-Type: <unknown> #> <EMPTY BODY>
GET( "http://httpbin.org/basic-auth/user/passwd", authenticate("user", "passwd") )
#> Response [http://httpbin.org/basic-auth/user/passwd] #> Date: 2020-08-17 22:22 #> Status: 200 #> Content-Type: application/json #> Size: 47 B #> { #> "authenticated": true, #> "user": "user" #> }