From 310e3db75f332a2165fb9f87ffd20920abfea2ad Mon Sep 17 00:00:00 2001 From: gongcastro Date: Wed, 4 Sep 2024 15:33:04 +0200 Subject: [PATCH] Use keyring instead of .Renviron --- R/connect.R | 8 ++------ vignettes/bvq-connect.Rmd | 12 ++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/R/connect.R b/R/connect.R index 8a288d5..d8dad63 100644 --- a/R/connect.R +++ b/R/connect.R @@ -42,18 +42,14 @@ bvq_connect <- function(google_email = NULL, # if key exists, use it to log in tryCatch( suppressWarnings( - formr::formr_connect( - email = formr_email, - password = password, - host = "https://formr.org/" - ) + formr::formr_connect(keyring = "formr") ), error = function(e) { cli_abort( strwrap( prefix = " ", initial = "", - "Could not connect to {.url https://formr.org/}. Please check your internet connection or make sure you have set the right formr password in a {.file .Renviron} file, under the name {.envvar FORMR_PWD}." + "Could not connect to {.url https://formr.org/}. Please check your internet connection or make sure you have set the right keyring as formr using {.code formr::formr_store_keys} (see vignettes)." ) ) } diff --git a/vignettes/bvq-connect.Rmd b/vignettes/bvq-connect.Rmd index 1b3f6b8..550e133 100644 --- a/vignettes/bvq-connect.Rmd +++ b/vignettes/bvq-connect.Rmd @@ -16,6 +16,18 @@ knitr::opts_chunk$set( BVQ is currently a developing package for internal use at the [Center for Brain and Cognititon](https://www.upf.edu/web/cbc) (CBC). For this reason, logging in requires a password that can be required by writing to the maintainer of this package ([gongarciacastro@gmail.com](mailto:gongarciacastro@gmail.com)). +---- + +**EDIT**: Since a few versions of the formr R package---which bvq uses---it is encouraged to use keyring to provide passwords when connecting to formr. Following these guidelines, it is recommended to set a keyring for formr in each local machine where bvq will be used. Please, do so as follows: + +```r +formr::formr_store_keys("formr") +``` + +When prompted, provide the apropriate email and password. These will be stored in the local machine, and will be retrieved by bvq whenever necessary without having to provide a password every time. + +---- + If you have already acquired the password, **please, do not include this password in your R scripts or anywhere they can accidentally be made public**. Instead, store the password as a variable named `FORMR_PWD` in the .Renviron file in your home or project directory. You can create or open a .Renviron file from your R console to include your newly acquired password using the `edit_r_environ()` from the [usethis](https://usethis.r-lib.org/) package: ```