From ada0a80f8a8d1704c94f2efd87e93538829d3bb0 Mon Sep 17 00:00:00 2001 From: Jenny Bryan Date: Mon, 4 May 2020 08:18:04 -0700 Subject: [PATCH] Catch `email = ""` specifically Closes #132 --- R/Gargle-class.R | 9 +++++++-- man/Gargle-class.Rd | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/R/Gargle-class.R b/R/Gargle-class.R index 4f439dfd..20dce30b 100644 --- a/R/Gargle-class.R +++ b/R/Gargle-class.R @@ -74,7 +74,7 @@ gargle2.0_token <- function(email = gargle_oauth_email(), #' `"~/.R/gargle/gargle-oauth"`, i.e. at the user level. In contrast, the #' default location for `Token2.0` is `./.httr-oauth`, i.e. in current working #' directory. `Gargle2.0` behaviour makes it easier to reuse tokens across -#' projects and makes it less likely that tokens are accidentally synched to a +#' projects and makes it less likely that tokens are accidentally synced to a #' remote location like GitHub or DropBox. #' * Each `Gargle2.0` token is cached in its own file. The token cache is a #' directory of such files. In contrast, `Token2.0` tokens are cached as @@ -115,7 +115,12 @@ Gargle2.0 <- R6::R6Class("Gargle2.0", inherit = httr::Token2.0, list( is_string(package), is.list(params) ) - + if (identical(email, "")) { + abort(paste0( + "`email` must not be \"\" (the empty string)\n", + "Do you intend to consult an env var, but it's unset?" + )) + } if (isTRUE(email)) { email <- "*" } diff --git a/man/Gargle-class.Rd b/man/Gargle-class.Rd index d445b898..8a5a6c83 100644 --- a/man/Gargle-class.Rd +++ b/man/Gargle-class.Rd @@ -17,7 +17,7 @@ work with Google APIs with multiple identities. \code{"~/.R/gargle/gargle-oauth"}, i.e. at the user level. In contrast, the default location for \code{Token2.0} is \code{./.httr-oauth}, i.e. in current working directory. \code{Gargle2.0} behaviour makes it easier to reuse tokens across -projects and makes it less likely that tokens are accidentally synched to a +projects and makes it less likely that tokens are accidentally synced to a remote location like GitHub or DropBox. \item Each \code{Gargle2.0} token is cached in its own file. The token cache is a directory of such files. In contrast, \code{Token2.0} tokens are cached as