Skip to content

Instantly share code, notes, and snippets.

@btupper
Created April 27, 2021 12:36
Show Gist options
  • Save btupper/e2ba7b6b3a63827265a4597d865db0fd to your computer and use it in GitHub Desktop.
Save btupper/e2ba7b6b3a63827265a4597d865db0fd to your computer and use it in GitHub Desktop.
Google tokens
# Getting and saving a token for accessing documents in Google Drive
# this takes you through an interactive session tp exchange passcodes
token <-gargle::token_fetch(scopes = c("email", "https://www.googleapis.com/auth/drive"))
# then save it for use in another session
saveRDS(x, "~/.httr-token.rds")
token <- googlesheets::gs_auth(token = token)
# or for later session use
# token <- googlesheets::gs_auth(token = readRDS("~/.httr-token.rds"))
# See for more...
# https://support.rstudio.com/hc/en-us/articles/217952868-Generating-OAuth-tokens-for-a-server-using-httr
# https://cran.r-project.org/web/packages/googlesheets/vignettes/managing-auth-tokens.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment