Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use keyring instead of .Renviron #50

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions R/connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
)
)
}
Expand Down
12 changes: 12 additions & 0 deletions vignettes/bvq-connect.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([[email protected]](mailto:[email protected])).

----

**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:

```
Expand Down
Loading