Last active
December 5, 2017 04:05
-
-
Save fauxneticien/2dffa2066e65495eb90d840c70159443 to your computer and use it in GitHub Desktop.
Encode and decode authentication tokens for googlesheets R package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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