#' Authenticate with Tomorrow.io
#'
#' @return `NULL`. Sets request configuration using related key defined in the user's R environment.
#' @seealso Check out the Tomorrow.io API to get started and create a token: 'https://docs.tomorrow.io/reference/welcome'
#' @export
api_auth <- function() {
user_id = Sys.getenv("TOMORROWIO_KEY")
if (nchar(user_id) == 0 | is.null(user_id)) {
rlang::abort("Could not find a valid API key in the R environment. Please ensure that 'TOMORROWIO_KEY' is defined within the '.Renviron' file. (Edit your .Renviron with `usethis::edit_r_environ()`)")
}
## Create an authentication header using an api key stored in the user's R environment file and set request config
httr::add_headers(
"apikey" = user_id,
"content-type" = "application/json"
) %>%
httr::set_config()
return(invisible())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.