gmailr-configuration {gmailr}R Documentation

Configuring gmailr

Description

gmailr can be configured with various environment variables, which are accessed through wrapper functions that provide some additional smarts.

Usage

gm_default_email()

gm_default_oauth_client()

gm_default_email()

gm_default_email() returns the environment variable GMAILR_EMAIL, if it exists, and gargle::gargle_oauth_email(), otherwise.

gm_default_oauth_client()

gm_default_oauth_client() consults a specific set of locations, looking for the filepath for the JSON file that represents an OAuth client. This file can be downloaded from the APIs & Services section of the Google Cloud console https://console.cloud.google.com). The search unfolds like so:

Here's an inspirational snippet to move the JSON file you downloaded into the right place for auto-discovery by gm_auth_configure():

path_old <- "~/Downloads/client_secret_123-abc.apps.googleusercontent.com.json"
d <- fs::dir_create(rappdirs::user_data_dir("gmailr"), recurse = TRUE)
fs::file_move(path_old, d)

See Also

Since gmailr uses the gargle package to handle auth, gargle's configuration is also relevant, which is mostly accomplished through options and associated accessor functions.

Other auth functions: gm_auth_configure(), gm_auth(), gm_deauth(), gm_scopes()

Examples

gm_default_email()

withr::with_envvar(
  c(GMAILR_EMAIL = "jenny@example.com"),
  gm_default_email()
)

gm_default_oauth_client()

withr::with_envvar(
  c(GMAILR_OAUTH_CLIENT = "path/to/my-client.json"),
  gm_default_oauth_client()
)

[Package gmailr version 2.0.0 Index]