R/token.r

Defines functions delete_token token_file set_token

Documented in delete_token

set_token <- function(token) {
  tf <- token_file()
  saveRDS(token, tf)
  Sys.chmod(tf, mode = "0600")
}

token_file <- function() {
  path <- Sys.getenv("HOME")
  if (path == "") path <- normalizePath("~")
  paste0(path, "/.annotinder.rds")
}

#' Delete backend API token
#'
#' Just in case you really want to.
#'
#' @return Nothing, just deletes the thing
#' @export
#'
#' @examples
#' delete_token()
delete_token <- function() {
  file.remove(token_file())
}
ccs-amsterdam/ccsAnnotator documentation built on March 19, 2024, 2:14 a.m.