R/bq_auth_for_rmd.R

Defines functions bq_auth_for_rmd

Documented in bq_auth_for_rmd

library("bigrquery")

bq_auth_for_rmd <- function(){
  if (!interactive() && Sys.getenv("GOOGLE_AUTH_USER") != "") {
    message("Authenticating as ", Sys.getenv("GOOGLE_AUTH_USER"))
    bq_auth(email = Sys.getenv("GOOGLE_AUTH_USER"))
  } else {
    bq_auth()
    message("********************************************")
    message("To automatically authenticate with Google as ", bq_user(), ", run the following in Terminal:")
    message("printf \"\\nGOOGLE_AUTH_USER=", bq_user(), "\" >> ~/.REnviron")
    message("********************************************")
  }
}
epuidokas/bqauthrmd documentation built on Nov. 4, 2019, 11:56 a.m.