generate_token: Generate a token

View source: R/get_token.R

generate_tokenR Documentation

Generate a token

Description

Generate ArcGIS Access tokens with credentials

Usage

generate_token(endpoint, username, password, expiration = 60)

Arguments

endpoint

the endpoint against which to request the token. this is generally in the format of: ⁠https://{host}:{port}/{site}/tokens/generateToken⁠ e.g: ⁠https://sampleserver6.arcgisonline.com/arcgis/tokens/generateToken⁠

username

your ArcGIS online username. You should make an effort to protect this by accessing it from an environment variable so that it isn't saved in your source code or .Rhistory file.

password

your ArcGIS online password. You should make an effort to protect this by accessing it from an environment variable so that it isn't saved in your source code or .Rhistory file.

expiration

The token expiration time in minutes (defaults to 60)

Details

This functino enables a user to generate a token for accessing ArcGIS services where Oauth2.0 isn't possible. The documentation is here: https://developers.arcgis.com/rest/services-reference/generate-token.htm You should make an effort to protect your username in password so that it isn't saved in the source code. Some good options are here: https://cran.r-project.org/web/packages/httr/vignettes/secrets.html

You could write a wrapper function around this function which gets your credentials from an environment variable, calls the function and returns a token. getarc may provide this functionality eventually.


MatthewJWhittle/getarc documentation built on April 22, 2023, 12:16 p.m.