Skip to content

Commit

Permalink
allow developer token, update documentation
Browse files Browse the repository at this point in the history
changed order of developer_token in box_auth
  • Loading branch information
danielruss committed Mar 17, 2023
1 parent 608f02e commit 7e17015
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Suggests:
usethis,
covr
VignetteBuilder: knitr
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RdMacros: lifecycle
27 changes: 17 additions & 10 deletions R/boxr_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#' @param interactive `logical`, indicates that the authorization process
#' will be interactive (requiring user input to the R console, and/or a
#' visit to [box.com](https://developer.box.com/docs)).
#' @param developer_token `character`, Optional developer token used for
#' authentication.
#' @param write.Renv **deprecated**.
#' @param ... Other arguments passed to [httr::oauth2.0_token()].
#'
Expand All @@ -71,7 +73,7 @@
#'
box_auth <- function(client_id = NULL, client_secret = NULL,
interactive = TRUE, cache = "~/.boxr-oauth",
write.Renv, ...) {
write.Renv, developer_token= NULL, ...) {

# deprecate write.Renv
if (!missing(write.Renv)) {
Expand Down Expand Up @@ -161,16 +163,21 @@ box_auth <- function(client_id = NULL, client_secret = NULL,
base_url = "https://app.box.com/api/oauth2"
)

insistent_token <- purrr::insistently(httr::oauth2.0_token, quiet = FALSE)
if (is.null(developer_token)){
insistent_token <- purrr::insistently(httr::oauth2.0_token, quiet = FALSE)

box_token <-
insistent_token(
box_endpoint,
box_app,
use_oob = getOption("httr_oob_default"),
cache = cache,
...
)
box_token <-
insistent_token(
box_endpoint,
box_app,
use_oob = getOption("httr_oob_default"),
cache = cache,
...
)
} else {
credentials <- list(access_token=developer_token,token_type="bearer")
box_token <- httr::oauth2.0_token(box_endpoint, box_app, credentials = credentials)
}

if (!exists("box_token")) {
stop("Login at box.com failed; unable to connect to API.")
Expand Down
8 changes: 7 additions & 1 deletion man/box_auth.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e17015

Please sign in to comment.