vignettes/alternative-browser.md

Use an alternative browser

Jennifer Bryan r Sys.Date()

What if you want to do auth in a non-default browser? Examples below show requests for Google Chrome or Safari on Mac OS X.

At runtime, the browser is given via the browser element of options().

getOption("browser")
## function (url) 
## {
##     .Call("rs_browseURL", url)
## }
## <environment: 0x10493db78>

Two alternatives to change that temporarily for gs_auth():

Using just base R facilities.

library(googlesheets)

op <- options(browser = "/usr/bin/open -a '/Applications/Google Chrome.app'")
#op <- options(browser = "/usr/bin/open -a '/Applications/Safari.app'")
gs_auth()
options(op)

Using with withr package.

library(withr)
library(googlesheets)

with_options(
  #  list(browser = "/usr/bin/open -a '/Applications/Safari.app'"),
  list(browser = "/usr/bin/open -a '/Applications/Google Chrome.app'"),
  gs_auth()
)


dakota1063/dddd documentation built on May 25, 2019, 4:21 p.m.