Skip to contents

Prompts the user to input a valid REDCap API token and stores it as an environment variable for the current R session. Instead of using this function you should consider setting your token within your REnviron file which can be edited with edit_r_environ.

Usage

set_REDCap_token(DB, ask = T)

Arguments

DB

A validated `DB` object containing REDCap project data and settings. Generated using load_DB or setup_DB

ask

Logical (TRUE/FALSE). If TRUE, asks the user for confirmation before overwriting an existing valid token. Default is `TRUE`.

Value

Invisible. A message is printed to confirm the token is successfully set.

Details

If a valid token already exists in the R session, the function notifies the user and asks whether they want to replace it. The user is guided to provide a new token through the console. It is strongly discouraged to include API tokens directly within R scripts. The token is validated internally and stored using `Sys.setenv()`.

See also

For the function to work you need to have a valid DB object from setup_DB(). See our REDCap Tokens Article

Other Token Functions: test_REDCap_token(), view_REDCap_token()