You first need to register as a user (if you haven't already) at the Human Mortality Database. To now set a session pass in your username and password from your account or alternatively, you can store your username and password in the .Renviron file containing
HMD_USERNAME=<YOUR USERNAME>
HMD_PASSWORD=<YOUR PASSWORD>
Usage
hmd_session(
username = Sys.getenv("HMD_USERNAME"),
password = Sys.getenv("HMD_PASSWORD")
)