R/ct_auth3.R

Defines functions ct_auth3

Documented in ct_auth3

#' POST request to retreive a 3-legged token
#'
#' \code{ct_auth2} 3-Legged authentication with the Citi API
#'
#' For 3-legged authentication with the Citi API. Returns the access token to be
#' passed for subsequent calls.
#'
#' @param
#' @return first get request returns an authorization code
#'
#' @examples
#' ct_token()
#' ct_token()
#'
#' \dontrun{
#'
#' }

ct_auth3 <- function(client_id = NULL) {
  # build the inputs for the endpoint
           endpoint <- "authCode/oauth2/authorize?"
           response <- "response_type=code&"
           client <- "scope=accounts_details_transactions&"
           scope <- "countryCode=us&"
           country <- "businessCode=gcb&"
           bc <- "locale=en_US&"
           locale <- "state=bdd669c2-1c8e-4e1f-3676-77db2c1647db&"
           state <- "redirect_uri=https://google.com"
           redirect <- paste0("&client_id=", Sys.getenv("CT_CLIENT_ID"))

  httr::GET(url = paste0("https://sandbox.apihub.citi.com/gcb/api/",
                         endpoint,
                         response,
                         client,
                         scope,
                         country,
                         bc,
                         locale,
                         state,
                         redirect),
            httr::accept_json()
  )

  ## three leg auth
  ## GET opens login page for client auth -- pass
  ## Returns access token in redirect URL
  ## GET account information using access token
}
bill-ash/citiR documentation built on Nov. 14, 2019, 12:12 a.m.