Learn R Programming

crunch (version 1.30.4)

setupCrunchAuth: Helper for switching between API keys and urls

Description

Credentials can be stored in the options or environment variables with the following structure (option = crunch.api.<ID> or environment variable R_CRUNCH_API_<ID>) where <ID> is a string. Then you can use this function to choose which credentials you want to use.

Usage

setupCrunchAuth(id)

Arguments

id

A string indicating the id of the credentials

Examples

Run this code
if (FALSE) {
# Using crunch options:
set_crunch_opts(
    crunch.api.account1 = "https://company1.crunch.io/api/",
    crunch.api.key.account1 = "MY KEY"
)

# Or with environment variables
Sys.setenv(
    "R_CRUNCH_API_ACCOUNT2" = "https://company2.crunch.io/api/",
    "R_CRUNCH_API_KEY_ACCOUNT2" = "ANOTHER KEY"
)

# Can now switch between accounts
setupCrunchAuth("account1")
crunch_sitrep()

setupCrunchAuth("account2")
crunch_sitrep()
}

Run the code above in your browser using DataLab