It is the main fonction to use for accessing RTE Data API. It will request an access token for the current session if none currently exists and be valid.

datarte_auth(token = NULL, client_id = NULL, client_secret = NULL,
  cache = FALSE)

Arguments

token

optional argument. it exists to supply manually a token.

  • if NULL (the default), the current token for the active session will be used.

  • if a character, it assumes to be the path to a rds file containing a valid Token2.0 object from httr

  • a Token2.0 object directly

client_id

character. the client id for the app. default NULL - will use the RTE_API_CLIENT environment variable.

client_secret

character. the client secret for the app. default NULL

  • will use the RTE_API_SECRET environment variable.

cache

logical or a string. TRUE to cache the access token into a file. A string means use the specified file. See httr::oauth2.0_token() for details.

Value

invisibly the Token which is saved for the current session, and will be used when needed.

Details

You can configure your R session to use always some client and secret by setting RTE_API_CLIENT and RTE_API_SECRET environment variable with base::Sys.setenv()

References

This function is inspired by googlesheet package and its Oauth2 system.

Examples

# NOT RUN {
client_id <- "cliend_id"
client_secret <- "client_secret"
datarte_auth(client_id = client_id, client_secret = client_secret, cache = F)
# }