Setting up your rgbif environment with username and password

If you want to run downloads using rgbif::occ_download(), you need…

  • user : GBIF username
  • pwd : GBIF password
  • email : Your E-mail

Saving these inline in a script file is not usually the best option because you might forget your password is in some file and share it to a public repository like GitHub, Zenodo, or Dryad.

Not a great idea :frowning:

user = "jwaller"
pwd = "please_dont_steal_my_password_123"
email = "jwaller@gbif.org"

rgbif::occ_download(
pred("country", "US"),
user=user,pwd=pwd,email=email
)

Much better :slight_smile:

The best way to allow rgbif access to your GBIF credentials is to save them in your .Renviron file, since users typically don’t share this file with others.

The easiest way to edit this file is by running usethis::edit_r_environ().

Edit your .Renviron to look like this:

GBIF_USER="jwaller"
GBIF_PWD="safe_fake_password123"
GBIF_EMAIL="jwaller@gbif.org"

Now you should be able to run rgbif::occ_download() with no user, pwd, or email!!

3 Likes

If you use Rstudio you can also use:

gbif_user <- rstudioapi::askForPassword("GBIF user")
gbif_pwd <- rstudioapi::askForPassword("GBIF password")
gbif_email <- rstudioapi::askForPassword("GBIF email")

on your script to display an interactive prompt.

1 Like