neon_api_token: Install a NEON API token in Your '.Renviron' File for...

View source: R/neon_api_token.R

neon_api_tokenR Documentation

Install a NEON API token in Your .Renviron File for repeated Use

Description

This function will add your NEON API token to your .Renviron file so it can be called securely without being stored in your code. After you have installed your key, it can be called any time by typing Sys.getenv("NEON_TOKEN") and can be used in package functions by simply typing NEON_TOKEN If you do not have an .Renviron file, the function will create on for you. If you already have an .Renviron file, the function will append the key to your existing file, while making a backup of your original file for disaster recovery purposes. This function was adapted from census_api_key() in the tidycensus library. https://CRAN.R-project.org/package=tidycensus.

Usage

neon_api_token(token, overwrite = FALSE, install = FALSE)

Arguments

token

The API token provided to you from the NEON formatted in quotes. A token can be acquired at https://www.neonscience.org/resources/learning-hub/tutorials/api-token-setup.

overwrite

If this is set to TRUE, it will overwrite an existing NEON_TOKEN that you already have in your .Renviron file.

install

if TRUE, will install the token in your .Renviron file for use in future sessions. Defaults to FALSE.

See Also

[get_neon_api_token()]

Examples


## Not run: 
neon_api_token("YOUR_TOKEN_HERE", install = TRUE)
# First time, reload your environment so you can use the key without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("NEON_API_TOKEN")

## End(Not run)

## Not run: 
# If you need to overwrite an existing key:
neon_api_token("111111abc", overwrite = TRUE, install = TRUE)
# First time, relead your environment so you can use the token without restarting R.
readRenviron("~/.Renviron")
# You can check it with:
Sys.getenv("NEON_TOKEN")

## End(Not run)

neonSoilFlux documentation built on July 3, 2026, 5:07 p.m.