Install or retrieve a Mapbox access token in your .Renviron for repeated use
Source:R/accounts.R
mb_access_token.Rd
See the Mapbox API documentation for more information on access tokens and token scopes.
Usage
mb_access_token(token, overwrite = FALSE, install = FALSE)
get_mb_access_token(
token = NULL,
default = c("MAPBOX_PUBLIC_TOKEN", "MAPBOX_SECRET_TOKEN"),
secret_required = FALSE
)
list_tokens(
username,
default = NULL,
limit = NULL,
sortby = "created",
usage = NULL,
access_token = NULL
)
Arguments
- token
A Mapbox access token; can be public (starting with 'pk') or secret (starting with 'sk') scope, which the function will interpret for you.
- overwrite
Whether or not to overwrite an existing Mapbox access token. Defaults to
FALSE
.- install
if
TRUE
, will install the key in your.Renviron
file for use in future sessions. Defaults toFALSE
.- default
If
TRUE
, will only include the default token for an account. IfFALSE
, will include all other tokens except for the default. Defaults toNULL
.- secret_required
If
TRUE
, a secret token is required. IfFALSE
, the default token is provided first and the other token provided second if the first is unavailable.- username
The Mapbox username for which you'd like to list access tokens.
- limit
The maximum number of tokens to return. Defaults to
NULL
.- sortby
How to sort the returned tokens; one of
"created"
or"modified"
.- usage
If
"pk"
, returns only public tokens; if"sk"
, returns only secret tokens. Defaults toNULL
, which returns all tokens in the scope of the supplied access token.- access_token
Your Mapbox access token. If left
NULL
, will first check to see if you have a secret token stored in .Renviron, then a public token.
Examples
if (FALSE) { # \dontrun{
my_token <- "..." # The token generated from your Mapbox account
mb_access_token(my_token, install = TRUE)
Sys.getenv("MAPBOX_PUBLIC_TOKEN")
get_mb_access_token()
} # }
if (FALSE) { # \dontrun{
token_list <- list_tokens(
username = "kwalkertcu", # You would use your own username here
limit = 10,
sortby = "modified" #'
)
} # }