Skip to contents

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()
#> <gargle_oauth_client>
#> name: trackdown-rpackage
#> id: 550669979075-48g4eihu9hb0k8m3odd9if0j55gk022a.apps.googleusercontent.com
#> secret: <REDACTED>
#> type: installed

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()
}
#> Loading required package: httr
#> 
#> Attaching package: ‘httr’
#> The following object is masked from ‘package:trackdown’:
#> 
#>     upload_file
#> <gargle_oauth_client>
#> name: trackdown-rpackage
#> id: 550669979075-48g4eihu9hb0k8m3odd9if0j55gk022a.apps.googleusercontent.com
#> secret: <REDACTED>
#> type: installed

if (FALSE) {
# 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"
)
}