Sometimes when using connectapi
, customizing HTTP
requests is desirable. For instance, some common use cases are:
This is possible with connectapi
thanks to the
underlying library in use, httr
.
When you initialize a connectapi
API client, you
implicitly create a httr
HTTP client. The httr
package allows you to configure your HTTP requests globally using
httr::set_config()
or in a scoped variant
httr::with_config
. We will walk through a few examples
below.
Sometimes when first setting up a server, it is common to use self-signed certificates. This is generally bad for reliable communication and security (as there is no reason for any computer to trust this server as a “self-declared” trustworthy actor).
However, it can be useful while the organization’s Certificate Authority (CA) is in the process of issuing a valid certificate, or while a certificate is procured from a public CA.
# disabling certificate trust (can allow man-in-the-middle attacks, etc.)
httr::set_config(httr::config(ssl_verifypeer = 0, ssl_verifyhost = 0))
# should work
client <- connect()
get_users(client)
You can also do this in a more scoped fashion:
Suffice it to say that effectively using Kerberos for HTTP is a bit
of an advanced topic. However, it is possible with
httr
.
It is worth noting that today, this interferes with API key authentication, which we are hoping to improve in a future release of Posit Connect.