• read_scihub_login() reads the SciHub login information;

  • write_scihub_login() saves new username and password;

  • check_scihub_login() checks their validity;

  • is_scihub_configured() check if SciHub credentials are configured.

Login information is stored in a file apihub.txt inside the ".sen2r" subfolder of the home directory. These functions allow reading or writing this file, and editing it from the GUI. In case file apihub.txt is missing, read_scihub_login() searches inside the environmental variables SCIHUB_USER and SCIHUB_PASSWORD.

read_scihub_login(apihub_path = NA)

is_scihub_configured()

check_scihub_login(username, password, service = "apihub")

check_scihub_connection(service = "apihub")

write_scihub_login(
  username,
  password,
  apihub_path = NA,
  check = TRUE,
  append = FALSE
)

Arguments

apihub_path

Path of the file in which login information is saved. If NA (default) it is automatically read from the package default location.

username

SciHub username.

password

SciHub password.

service

Character: it can be "dhus" or "apihub" (default).

check

Logical: if TRUE (default), new credentials are checked before writing them on apihub_path (if they are invalid, an error is provided); if FALSE, they are directly written.

append

Logical: if TRUE, new credentials are added to the ones existing within apihub_path; if FALSE (default), apihub_path is replaced with the new ones.

Value

read_scihub_login() returns a matrix of credentials, in which username is in the first column, password in the second.

is_scihub_configured() returns TRUE if credentials can be accessed, FALSE if not.

check_scihub_login() returns TRUE if credentials are valid, FALSE elsewhere.

check_scihub_connection() returns TRUE if internet connection is available and SciHub is accessible, FALSE otherwise.

write_scihub_login() returns NULL.

Details

Notice that new/recently updated SciHub credentials are recognised by API Hub with a delay of about one week (see https://scihub.copernicus.eu/twiki/do/view/SciHubWebPortal/APIHubDescription for details).

For this reason, newly created credentials can not immediately be used by sen2r, and password edits on old credentials are not immediately recognised.

Note

License: GPL 3.0

References

L. Ranghetti, M. Boschetti, F. Nutini, L. Busetto (2020). "sen2r": An R toolbox for automatically downloading and preprocessing Sentinel-2 satellite data. Computers & Geosciences, 139, 104473. doi: 10.1016/j.cageo.2020.104473 , URL: https://sen2r.ranghetti.info/.

Author

Luigi Ranghetti, phD (2019) luigi@ranghetti.info

Lorenzo Busetto, phD (2019)

Examples

# \donttest{ is_scihub_configured()
#> [1] TRUE
# } if (FALSE) { check_scihub_connection() check_scihub_login("username", "password") write_scihub_login("username", "password") read_scihub_login() }