Skip to contents

Stores an authentication token in a process environment variable named "<service>_<name>". The token is never written to disk. If a non-empty variable with that name already exists, the function refuses to overwrite it unless overwrite = TRUE (e.g. to rotate an expired token).

Usage

af_store_token(name, token, service = "apifetch", overwrite = FALSE)

Arguments

name

The identifier for this token (e.g. a dataset or resource name).

token

The authentication token (character).

service

A namespace prefix grouping tokens for one API. Default "apifetch".

overwrite

Replace an existing token? Default FALSE.

Value

Invisibly NULL; called for its side effect.

Examples

bdpe <- af_store_token("dengue", "your-token-here", service = "BigDataPE")
#> ✔ Token stored in environment variable: `BigDataPE_dengue`