Skip to contents

The function reads a cached token when one exists. Otherwise, it opens the system browser and asks Google to authorize the application. By default, tokens are stored in the user's R cache directory rather than the project directory.

Usage

yt_oauth(
  app_id = NULL,
  app_secret = NULL,
  scope = "ssl",
  token = file.path(tools::R_user_dir("tuber", "cache"), "oauth-token.rds"),
  ...
)

Arguments

app_id

client id. Required the first time; optional once a token is cached.

app_secret

client secret. Required the first time; optional once a token is cached.

scope

Character. ssl, basic, own_account_readonly, upload_and_manage_own_videos, channel_memberships, partner, and partner_audit. Required. ssl and basic are basically interchangeable. Default is ssl.

token

Path to the token cache. The default is `file.path(tools::R_user_dir("tuber", "cache"), "oauth-token.rds")`.

...

Additional arguments passed to oauth_flow_auth_code

Value

The OAuth token, invisibly. The function also sets the `google_token` option and saves the token at `token`.

Details

The cache file holds the token together with the OAuth client, including the client secret, because an access token lasts an hour and can only be refreshed by the client that minted it. Treat the file as a credential.

Examples

 if (FALSE) { # \dontrun{
yt_oauth(
  "YOUR-CLIENT-ID.apps.googleusercontent.com",
  "YOUR-CLIENT-SECRET"
)
} # }