trackdown_auth_configure: Edit and view auth configuration

View source: R/trackdown_auth.R

trackdown_auth_configureR Documentation

Edit and view auth configuration

Description

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

  • OAuth client, which is used when obtaining a user token.

See the vignette("get-api-credentials", package = "gargle") for more. If the user does not configure these settings, internal defaults are used.

trackdown_oauth_client() retrieves the currently configured OAuth client.

Usage

trackdown_auth_configure(client, path, app = deprecated())

trackdown_oauth_client()

Arguments

client

A Google OAuth client, presumably constructed via gargle::gargle_oauth_client_from_json(). Note, however, that it is preferred to specify the client with JSON, using the path argument.

path

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

app

[Deprecated] Replaced by the client argument.

Value

  • trackdown_auth_configure(): An object of R6 class gargle::AuthState, invisibly.

  • trackdown_oauth_client(): the current user-configured OAuth client.

See Also

Other auth functions: trackdown_auth(), trackdown_deauth()

Examples

# see the current user-configured OAuth client (probaby `NULL`)
trackdown_oauth_client()

if (require(httr)) {

  # store current state, so we can restore
  original_client <- trackdown_oauth_client()

  # bring your own client via client id (aka key) and secret
  google_client <- gargle::gargle_oauth_client(
    id = "123456789.apps.googleusercontent.com",
    secret = "abcdefghijklmnopqrstuvwxyz",
    name = "my-awesome-google-api-wrapping-package",
  )
  trackdown_auth_configure(client = google_client)

  # confirm current client
  trackdown_oauth_client()
  
  # restore original state
  trackdown_auth_configure(client = original_client)
  trackdown_oauth_client()
}

## Not run: 
# bring your own client via JSON downloaded from Google Developers Console
trackdown_auth_configure(
  path = "/path/to/the/JSON/you/downloaded/from/google/dev/console.json"
)

## End(Not run)


ekothe/trackdown documentation built on June 28, 2023, 4:57 p.m.