Learn R Programming

mapboxapi (version 0.2)

mb_access_token: Install a Mapbox access token in your .Renviron for repeated use

Description

Install a Mapbox access token in your .Renviron for repeated use

List tokens from a Mapbox account

Usage

mb_access_token(token, overwrite = FALSE, install = FALSE)

list_tokens( username, default = NULL, limit = NULL, sortby = "created", usage = NULL, access_token = NULL )

Arguments

token

The 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.

username

The Mapbox username for which you'd like to list access tokens.

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.

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 blank, 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

Run this code
# NOT RUN {
my_token <- "..." # The token generated from your Mapbox account
mb_access_token(my_token, install = TRUE)
Sys.getenv("MAPBOX_PUBLIC_TOKEN")
# }
# NOT RUN {
token_list <- list_tokens(
  username = "kwalkertcu", # You would use your own username here
  limit = 10,
  sortby = "modified"#'
)

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab