
googledrive configuration
Source:R/googledrive-package.R, R/utils-ui.R
      googledrive-configuration.RdSome aspects of googledrive behaviour can be controlled via an option.
Usage
local_drive_quiet(env = parent.frame())
with_drive_quiet(code)Auth
Read about googledrive's main auth function, drive_auth(). It is powered
by the gargle package, which consults several options:
- Default Google user or, more precisely, - email: see- gargle::gargle_oauth_email()
- Whether or where to cache OAuth tokens: see - gargle::gargle_oauth_cache()
- Whether to prefer "out-of-band" auth: see - gargle::gargle_oob_default()
- Application Default Credentials: see - gargle::credentials_app_default()
Messages
The googledrive_quiet option can be used to suppress messages from
googledrive. By default, googledrive always messages, i.e. it is not
quiet.
Set googledrive_quiet to TRUE to suppress messages, by one of these
means, in order of decreasing scope:
- Put - options(googledrive_quiet = TRUE)in a start-up file, such as- .Rprofile, or at the top of your R script
- Use - local_drive_quiet()to silence googledrive in a specific scope
- Use - with_drive_quiet()to run a small bit of code silently
local_drive_quiet() and with_drive_quiet() follow the conventions of the
the withr package (https://withr.r-lib.org).
Examples
# message: "Created Drive file"
(x <- drive_create("drive-quiet-demo", type = "document"))
#> Created Drive file:
#> • drive-quiet-demo <id: 1Ry3RKwXMQRAEKvT3ANh5cdmkRHVD8-WPJYwsk6l9_hc>
#> With MIME type:
#> • application/vnd.google-apps.document
#> # A dribble: 1 × 3
#>   name             id       drive_resource   
#>   <chr>            <drv_id> <list>           
#> 1 drive-quiet-demo 1Ry3RKw… <named list [37]>
# message: "File updated"
x <- drive_update(x, starred = TRUE)
#> File updated:
#> • drive-quiet-demo <id: 1Ry3RKwXMQRAEKvT3ANh5cdmkRHVD8-WPJYwsk6l9_hc>
drive_reveal(x, "starred")
#> # A dribble: 1 × 4
#>   name             starred id       drive_resource   
#>   <chr>            <lgl>   <drv_id> <list>           
#> 1 drive-quiet-demo TRUE    1Ry3RKw… <named list [38]>
# suppress messages for a small amount of code
with_drive_quiet(
  x <- drive_update(x, name = "drive-quiet-works")
)
x$name
#> [1] "drive-quiet-works"
# message: "File updated"
x <- drive_update(x, media = drive_example_local("chicken.txt"))
#> File updated:
#> • drive-quiet-works <id: 1Ry3RKwXMQRAEKvT3ANh5cdmkRHVD8-WPJYwsk6l9_hc>
# suppress messages within a specific scope, e.g. function
unstar <- function(y) {
  local_drive_quiet()
  drive_update(y, starred = FALSE)
}
x <- unstar(x)
drive_reveal(x, "starred")
#> # A dribble: 1 × 4
#>   name              starred id       drive_resource   
#>   <chr>             <lgl>   <drv_id> <list>           
#> 1 drive-quiet-works FALSE   1Ry3RKw… <named list [38]>
# Clean up
drive_rm(x)
#> File deleted:
#> • drive-quiet-works <id: 1Ry3RKwXMQRAEKvT3ANh5cdmkRHVD8-WPJYwsk6l9_hc>