Skip to contents

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 to FALSE.

default

If TRUE, will only include the default token for an account. If FALSE, will include all other tokens except for the default. Defaults to NULL.

secret_required

If TRUE, a secret token is required. If FALSE, 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 to NULL, 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.

Value

A tibble of information about tokens in your Mapbox account.

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" #'
)
} # }