From a6e9f37c240f7e7e9ce38a4bf1bfcdf20b8615d2 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Wed, 11 Nov 2020 15:32:27 -0800 Subject: [PATCH] Don't init .auth object until .onLoad Creating the .auth object directly at the top-level means the code from gargle is snapshotted at build time. --- DESCRIPTION | 2 +- R/auth_gargle.R | 10 ++-------- R/options.R | 8 ++++++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index dbd5824..199170a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: googleAuthR Type: Package -Version: 1.3.0.9000 +Version: 1.3.0.9001 Title: Authenticate and Create Google APIs Description: Create R functions that interact with OAuth2 Google APIs easily, diff --git a/R/auth_gargle.R b/R/auth_gargle.R index f5612b1..d317c0f 100644 --- a/R/auth_gargle.R +++ b/R/auth_gargle.R @@ -3,15 +3,9 @@ #' Environment to store authentication credentials #' -#' Used to keep persistent state. +#' Used to keep persistent state. Initialized in .onLoad. #' @noRd -.auth <- gargle::init_AuthState( - package = "googleAuthR", - auth_active = TRUE - #app = NULL, - #api_key = NULL, - #cred = NULL -) +.auth <- NULL ## The roxygen comments for these functions are mostly generated from data diff --git a/R/options.R b/R/options.R index 1dc7570..8bf7656 100644 --- a/R/options.R +++ b/R/options.R @@ -1,5 +1,13 @@ .onLoad <- function(libname, pkgname) { + .auth <<- gargle::init_AuthState( + package = "googleAuthR", + auth_active = TRUE + #app = NULL, + #api_key = NULL, + #cred = NULL + ) + sys_or_null <- function(x){ sys <- Sys.getenv(x) if (sys == "") return(NULL)