R/acled_auth.R

Defines functions acled_auth

Documented in acled_auth

#' @title Authenticate a request via ACLED API OAuth endpoint.
#' @name acled_auth
#' @description Pings the ACLED API token endpoint for authentication using email and password.
#' @param req An ACLED API request.
#' @param username Email associated with ACLED account.
#' @param password User password associated with ACLED account.
#' @family API and Access
#' @returns Returns a modified HTTP request that will use OAuth for the ACLED API.
#' @examples
#' \dontrun{
#' acled_auth(req, email, password)
#' }
#' @seealso ACLED API Access guide <https://acleddata.com/api-documentation/getting-started>
#' @export
#' @md


acled_auth <- function(req, username, password = NULL) {

  token_url <- "https://acleddata.com/oauth/token"

  httr2::req_oauth_password(req,
                     client = httr2::oauth_client("acled", token_url),
                     username = username,
                     password = password
  )

}

Try the acledR package in your browser

Any scripts or data that you put into this service are public.

acledR documentation built on Sept. 9, 2025, 5:38 p.m.