token_from_response <- function()

in R/auth.R [31:39]


token_from_response <- function(response) {
  cont <- httr::content(response, as = "parsed")
  if (is.null(cont[["access_token"]])) {
    stop("Response does not contain a token.")
  }
  date <- response[["date"]]
  expiry <- as.POSIXct(date) + cont[["expires_in"]]
  graph_api_token(cont[["access_token"]], expiry, retrieved = date)
}