get_smarter_token: Get a SMARTER authentication token

Description Usage Arguments Value Configure environment variables Warning Examples

View source: R/auth.R

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

1
2
3
4
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:

1
2
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

1
2
3
4
5
6
token <- get_smarter_token()
## Not run: 

token <- get_smarter_token(username, password)

## End(Not run)

cnr-ibba/r-smarter-api documentation built on Jan. 14, 2022, 9:42 p.m.