generate_fitbitr_token: Generate an Oauth token

View source: R/setup.R

generate_fitbitr_tokenR Documentation

Generate an Oauth token

Description

Performs the OAuth 2.0 dance to create a token to use with the Fitbit API.

Usage

generate_fitbitr_token(
  app_name = "fitbitr",
  client_id = Sys.getenv("FITBIT_CLIENT_ID"),
  client_secret = Sys.getenv("FITBIT_CLIENT_SECRET"),
  callback = Sys.getenv("FITBIT_CALLBACK", "https://localhost:1410/"),
  scope = c("activity", "cardio_fitness", "electrocardiogram", "heartrate", "location",
    "nutrition", "oxygen_saturation", "profile", "respiratory_rate", "settings", "sleep",
    "social", "temperature", "weight"),
  cache = TRUE,
  use_basic_auth = TRUE,
  ...
)

Arguments

app_name

The name of your OAuth app. Default: fitbitr

client_id

Your Fitbit client ID

client_secret

Your Fitbit client secret

callback

Your Fitbit redirect URL

scope

The scopes to enable

cache

Do you want to cache your token? See oauth2.0_token for details

use_basic_auth

A boolean for whether or not to use basic auth in oauth2.0_token. Defaults to TRUE

...

additional arguments to be passed to oauth2.0_token

Details

Saves a token as .fitbitr_token which can then be used in the background to authorize requests

Value

Returns an OAuth 2.0 token (invisibly) that can be used to authorize requests to the Fitbit API. Also saves the token to .fitbitr_token.

Examples

## Not run: 
generate_fitbitr_token(
  client_id = <YOUR-CLIENT-ID>
  client_secret = <YOUR-CLIENT-SECRET>,
  cache = TRUE
)

## End(Not run)


fitbitr documentation built on March 31, 2023, 9:10 p.m.