What I just learned that there can be a couple of authentication methods used in R API wrapper packages but the most common ones are API Key
and OAuth 2.0
.
API Key
API Key
normally can be generated on a developer dashboard and can be regenerated later for security reason.
API Key
can be saved as an environment variable in a .Renviron
file and then we can use Sys.getenv()
to get access to it, as shown here: https://github.com/maelle/goodpress/blob/main/R/utils-http.R.
keyring
package is another common way to manage API Key
: key_set()
to create api key and key_get()
to get access to the api key, as shown here: https://github.com/lockedata/hubspot/blob/master/R/hubspot_key.R.
Lastly, there are two different ways to include an api key in api calls: including it as part of the URL or adding it in the HTTP header.