Learn R Programming

tuber (version 2.0.0)

yt_oauth: Set up Authorization

Description

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"),
  ...
)

Value

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

Arguments

app_id

client id; required; no default

app_secret

client secret; required; no default

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 oauth2.0_token

References

https://developers.google.com/youtube/v3/docs/

https://developers.google.com/youtube/v3/guides/auth/client-side-web-apps for different scopes

Examples

Run this code
 if (FALSE) {
yt_oauth(paste0("998136489867-5t3tq1g7hbovoj46dreqd6k5kd35ctjn",
                ".apps.googleusercontent.com"),
         "MbOSt6cQhhFkwETXKur-L9rN")
}

Run the code above in your browser using DataLab