The 2.0 release of hawkinR introduces a secure,
profile-based authentication system built on the S7 object-oriented
framework. By leveraging your computer’s native password manager and
formal S7 classes, you can now manage multiple team tokens securely
without ever hardcoding sensitive secrets into your R scripts.
On your local machine, hawkinR uses your computer’s
built-in password manager (Keychain on Mac, Credential Manager on
Windows) to encrypt your keys. You should never have to handle the
keyring package directly; hawkinR provides
helper functions to manage this for you.
You only need to do this once per machine or whenever you receive a new token from your Org Admin.
Once stored, connecting is a single line of code.
hawkinR retrieves your key, exchanges it for a temporary
access token, and sets up your “Active Connection” in the
background.
If you have “Team Scoped Tokens” for different groups, or if you are a consultant managing multiple organizations, you can save them under unique profile names.
Code snippet
When deploying to a server (like ShinyApps.io, Posit Connect, or a
Docker container), the keyring is typically unavailable. In
these “headless” environments, hawkinR looks for
Environment Variables.
Add a variable to your server’s environment or your
.Renviron file formatted as
HAWKIN_KEY_{PROFILE_NAME}.
While get_tests() usually finds the “Active Connection”
automatically, power users can manage connection objects manually using
S7 syntax.
# Create specific session objects
conn_a <- hd_connect(profile = "org_a")
conn_b <- hd_connect(profile = "org_b")
# Pass the connection as the first argument to any 'get' function
data_a <- get_tests(conn_a, from = "2024-01-01")
data_b <- get_tests(conn_b, from = "2024-01-01") Summary of Commands
| Function | Purpose |
|---|---|
| hd_auth_store(“name”) | Saves a key to your computer’s secure vault. |
| hd_auth_reset(“name”) | Deletes a key from your computer’s vault. |
| hd_connect(profile = “name”) | Initializes the session and sets it as “Active”. |
| get_tests(…) | Fetches data using the current Active connection. |