get_smarter_token: Get a SMARTER authentication token

View source: R/auth.R

get_smarter_tokenR Documentation

Get a SMARTER authentication token

Description

Authenticate through SMARTER API and returns a valid token. Token is also cached in package in order to be used by other functions. Calling this function another time will return the cached token if is still valid

Usage

get_smarter_token(
  username = Sys.getenv("SMARTER_API_USERNAME"),
  password = Sys.getenv("SMARTER_API_PASSWORD")
)

Arguments

username

the SMARTER username (or 'SMARTER_API_USERNAME' environment variable)

password

the SMARTER password (or 'SMARTER_API_PASSWORD' environment variable)

Value

Returns a valid token as a string

Configure environment variables

In order to not provide your SMARTER credentials within your code, you could set those values in your environment. You can call usethis::edit_r_environ() in order to track credentials in your .Renviron file using the Key=value syntax, for example:

SMARTER_API_USERNAME=<smarter username>
SMARTER_API_PASSWORD=<smarter password>

See Managing R with .Rprofile, .Renviron, Rprofile.site, Renviron.site, rsession.conf, and repos.conf for more information

Warning

SMARTER credentials MUST NOT be tracked in your code

Examples

token <- get_smarter_token()
## Not run: 

token <- get_smarter_token(username, password)

## End(Not run)

cnr-ibba/r-smarter-api documentation built on Nov. 1, 2022, 4:24 a.m.