cred_funs {gargle} | R Documentation |
Credential function registry
Description
Functions to query or manipulate the registry of credential functions
consulted by token_fetch()
.
Usage
cred_funs_list()
cred_funs_add(...)
cred_funs_set(funs, ls = deprecated())
cred_funs_clear()
cred_funs_list_default()
cred_funs_set_default()
local_cred_funs(
funs = cred_funs_list_default(),
action = c("replace", "modify"),
.local_envir = caller_env()
)
with_cred_funs(
funs = cred_funs_list_default(),
code,
action = c("replace", "modify")
)
Arguments
... |
< |
funs |
A named list of credential functions. |
ls |
|
action |
Whether to use
|
.local_envir |
The environment to use for scoping. Defaults to current execution environment. |
code |
Code to run with temporary credential function registry. |
Value
A list of credential functions or NULL
.
Functions
-
cred_funs_list()
: Get the list of registered credential functions. -
cred_funs_add()
: Register one or more new credential fetching functions. Function(s) are added to the front of the list. So:"First registered, last tried."
"Last registered, first tried."
Can also be used to remove a function from the registry.
-
cred_funs_set()
: Register a list of credential fetching functions. -
cred_funs_clear()
: Clear the credential function registry. -
cred_funs_list_default()
: Return the default list of credential functions. -
cred_funs_set_default()
: Reset the registry to the gargle default. -
local_cred_funs()
: Modify the credential function registry in the current scope. It is an example of thelocal_*()
functions in withr. -
with_cred_funs()
: Evaluatecode
with a temporarily modified credential function registry. It is an example of thewith_*()
functions in withr.
See Also
token_fetch()
, which is where the registry is actually used.
Examples
names(cred_funs_list())
creds_one <- function(scopes, ...) {}
cred_funs_add(one = creds_one)
cred_funs_add(two = creds_one, three = creds_one)
names(cred_funs_list())
cred_funs_add(two = NULL)
names(cred_funs_list())
# restore the default list
cred_funs_set_default()
# remove one specific credential fetcher
cred_funs_add(credentials_gce = NULL)
names(cred_funs_list())
# force the use of one specific credential fetcher
cred_funs_set(list(credentials_user_oauth2 = credentials_user_oauth2))
names(cred_funs_list())
# restore the default list
cred_funs_set_default()
# run some code with a temporary change to the registry
# creds_one ONLY
with_cred_funs(
list(one = creds_one),
names(cred_funs_list())
)
# add creds_one to the list
with_cred_funs(
list(one = creds_one),
names(cred_funs_list()),
action = "modify"
)
# remove credentials_gce
with_cred_funs(
list(credentials_gce = NULL),
names(cred_funs_list()),
action = "modify"
)