Skip to contents

Obtain an authorization token using your personal client_id and client_secret.

Official documentation: API Summary

Usage

create_auth_token(
  client_id = Sys.getenv("ARDUINO_API_CLIENT_ID"),
  client_secret = Sys.getenv("ARDUINO_API_CLIENT_SECRET"),
  store_token = "option",
  return_token = FALSE,
  silent = FALSE,
  ...
)

Arguments

client_id

Your client id (default is the environmental variable ARDUINO_API_CLIENT_ID)

client_secret

Your client secret (default is the environmental variable ARDUINO_API_CLIENT_SECRET)

store_token

Where your token is stored. If option it will be saved into the .Rprofile (not cross-session), if envir it will be saved as an environmental variable.

return_token

If TRUE returns the token value as output of the function.

silent

Whether to hide or show API method success messages (default FALSE)

...

Additional parameters needed for the body of the POST request:

  • token_url (default: https://api2.arduino.cc/iot/v1/clients/token/)

  • grant_type (default: client_credentials)

  • audience (default: https://api2.arduino.cc/iot/)

  • content_type (default: application/x-www-form-urlencoded)

Value

A token valid for Arduino IoT Cloud API. It can retrievable by getOption('ARDUINO_API_TOKEN') (if store_content = "option") or by Sys.getenv("ARDUINO_API_TOKEN") (if store_token = "envir")

Examples

if (FALSE) {
# Sys.setenv(ARDUINO_API_CLIENT_ID = 'INSERT CLIENT_ID HERE')
# Sys.setenv(ARDUINO_API_CLIENT_SECRET = 'INSERT CLIENT_SECRET HERE')

create_auth_token()
}