Skip to content

Instantly share code, notes, and snippets.

@fauxneticien
Last active December 5, 2017 04:05
Show Gist options
  • Select an option

  • Save fauxneticien/2dffa2066e65495eb90d840c70159443 to your computer and use it in GitHub Desktop.

Select an option

Save fauxneticien/2dffa2066e65495eb90d840c70159443 to your computer and use it in GitHub Desktop.
Encode and decode authentication tokens for googlesheets R package
library(base64enc)
token2text <- function(token_obj, txt_file) {
rds_path <- tempfile()
saveRDS(object = token_obj,
file = rds_path)
# return base64 string
writeLines(base64encode(rds_path), txt_file)
}
text2token <- function(txt_file) {
decoded_rds <- tempfile()
base64decode(file = txt_file,
output = decoded_rds)
readRDS(decoded_rds)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment