Configuring your environment
Source:vignettes/articles/Custom-Configurations.Rmd
Custom-Configurations.Rmd
By default, packages in the arcgis meta-package are
configured to work with ArcGIS Online. arcgis
utilizes
environment variables to determine how requests are crafted and where
requests are made. These environment variables are:
ARCGIS_HOST
ARCGIS_USER
ARCGIS_CLIENT
ARCGIS_SECRET
ARCGIS_TOKEN
Environment variable usage
ARCGIS_HOST
is used to to determine where authorization takes place. By default, this is"https://www.arcgis.com"
. This is because the packages, by default, interact with ArcGIS Online. To use a different portal, you will need to modify theARCGIS_HOST
path to url of that portal.ARCGIS_USER
variable is used to determine who actions are performed on behalf of. Notably, it is used in functions that modify or create resource such as functions fromarcgislayers
:create_service()
,add_item()
, andpublish_item()
.ARCGIS_CLIENT
andARCGIS_SECRET
environment variables are used only in theauth_client()
OAuth2 client flow authorization. See the article on authorization for more.ARCGIS_TOKEN
is used to fetch a users access token. These are retrieved using the variousauth_
functions ofarcgisutils
and set usingset_auth_token()
. Alternatively, theARCGIS_TOKEN
can be set to an API key.
Modifying your environment variables
Environment variables should never be
included in your code. Instead, they should be stored in an external
environment file such as an .Renvrion
file. See
usethis::edit_r_environ()
on how you can set these
variables. Generally, it is recommended that you have a project level
.Renviron
file that stores only the requisite environment
variables.