Learn R Programming

gmailr (version 1.0.1)

gm_auth_configure: Edit auth configuration

Description

These functions give more control over and visibility into the auth configuration than gm_auth() does. gm_auth_configure() lets the user specify their own:

  • OAuth app, which is used when obtaining a user token. See the vignette How to get your own API credentials for more. If the user does not configure these settings, internal defaults are used. gm_oauth_app() retrieves the currently configured OAuth app.

Usage

gm_auth_configure(
  key = "",
  secret = "",
  path = Sys.getenv("GMAILR_APP"),
  appname = "gmailr",
  ...,
  app = httr::oauth_app(appname, key, secret, ...)
)

gm_oauth_app()

Value

Arguments

key

consumer key, also sometimes called the client ID

secret

consumer secret, also sometimes called the client secret.

path

JSON downloaded from Google Cloud Platform Console, containing a client id (aka key) and secret, in one of the forms supported for the txt argument of jsonlite::fromJSON() (typically, a file path or JSON string).

appname

name of the application. This is not used for OAuth, but is used to make it easier to identify different applications.

...

Additional arguments passed to httr::oauth_app()

app

OAuth app, in the sense of httr::oauth_app().

See Also

Other auth functions: gm_deauth(), gm_scopes()

Examples

Run this code
if (FALSE) {
# see the current user-configured OAuth app (probaby `NULL`)
gm_oauth_app()

if (require(httr)) {

  # store current state, so we can restore
  original_app <- gm_oauth_app()

  # bring your own app via client id (aka key) and secret
  google_app <- httr::oauth_app(
    "my-awesome-google-api-wrapping-package",
    key = "123456789.apps.googleusercontent.com",
    secret = "abcdefghijklmnopqrstuvwxyz"
  )
  gm_auth_configure(app = google_app)

  # confirm current app
  gm_oauth_app()

  # restore original state
  gm_auth_configure(app = original_app)
  gm_oauth_app()
}

# bring your own app via JSON downloaded from Google Developers Console
gm_auth_configure(
  path = "/path/to/the/JSON/you/downloaded/from/google/dev/console.json"
)
}

Run the code above in your browser using DataLab