R/jira_auth.R

Defines functions jira_auth_check jira_auth

Documented in jira_auth

#' jira_auth
#'
#' Save your Jira API credentials to your environment
#' @param user The API user name
#' @param pass The API password
#' @param clear Clear your existing API key so that you can re-enter the user and secret values
#' @export

jira_auth <- function(user,pass,clear=FALSE) {

  require(keyring)

  if (clear == TRUE) {

    key_delete('jira_api')
    print('Jira API key deleted')

  }

  key_set_with_value('jira_api',username=user,password=pass)
  print('Jira API key set')

}

jira_auth_check <- function() {

  require(keyring)
  require(purrr)

  if (is_empty(key_get('jira_api') == TRUE)) {

    stop('You need to run jira_auth again to save your API credentials')

  }

  auth_list <- list()

  auth_list$user <- (key_list('jira_api'))$username
  auth_list$pass <- key_get('jira_api')

  return(auth_list)

}
neugelb/njira documentation built on Sept. 2, 2020, 7:02 p.m.