tokenfile <- tempfile()
# ---------- Create a password and store the tokens to token book ------
pass1 <- get_credential(
master_password = "my password",
service = "google.com:my_username",
special_chr = "@#$%^&*",
tokenfile = tokenfile
)
print(pass1)
# ---------- Query existing tokens ------
token_params <- get_credential(
method = "query",
tokenfile = tokenfile,
verbose = TRUE
)
print(token_params)
# ---------- retrieve stored password ----------
pass2 <- get_credential(
master_password = "my password",
service = "google.com",
tokenfile = tokenfile
)
identical(pass1, pass2)
# Using wrong master password
pass3 <- get_credential(
master_password = "wrong password",
service = "google.com",
tokenfile = tokenfile
)
identical(pass1, pass3)
# ---------- Replace token ----------
# Existing token will be replaced with a new token
pass4 <- get_credential(
master_password = "my password",
method = "replace",
service = "google.com",
special_chr = "@#$%^&*",
tokenfile = tokenfile
)
print(pass4)
identical(pass1, pass4)
Run the code above in your browser using DataLab