sq_auth: Log in to Square

Description Usage Arguments Examples

View source: R/auth.R

Description

Log in using a Personal Access Token or OAuth 2.0 authenticaion. OAuth does not require sharing a token, but will require creating a connected app in the dashboard. Once you add the app id and secret, anytime you use sq_auth without a personal access token, then you will be directed to your default web browser, asked to sign in to your Square account, and to grant the connected app permission to pass data back to you on your behalf. By default, the oauth token credentials are cached in a file named .httr-oauth-squareupr in the current working directory.

Usage

1
2
3
4
5
sq_auth(personal_access_token = NULL, token = NULL,
  app_id = getOption("squareupr.app_id"),
  app_secret = getOption("squareupr.app_secret"),
  callback_url = getOption("squareupr.callback_url"),
  cache = getOption("squareupr.httr_oauth_cache"), verbose = FALSE)

Arguments

personal_access_token

Square

token

optional; an actual OAuth 2.0 token object or the path to a valid token stored as an .rds file

app_id, app_secret, callback_url

the "App Id","App Secret", and "Callback URL" when using a connected app. NOTE: You must setup your own connected app and supply these arguments.

cache

logical or character; TRUE means to cache using the default cache file .httr-oauth-squareupr, FALSE means don't cache. A string means use the specified path as the cache file.

verbose

logical; do you want informative messages?

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# log in using personal access token
sq_auth(personal_access_token = "ThisIsATestToken") 

# log in using OAuth 2.0
# Via brower or refresh of .httr-oauth-squareupr
sq_auth()

# Save token and log in using it
saveRDS(.state$token, "token.rds")
sq_auth(token = "token.rds")

## End(Not run)

StevenMMortimer/squareupr documentation built on July 12, 2019, 1:45 a.m.