Skip to contents

Load or generate a YouTube OAuth token for use in the other functions in this package. The primary use of this function is to cache values early in a script (so the user can walk away). Otherwise the other functions in this package will prompt for authentication when needed. Once the values are cached, the rest of this package will use them by default for that client.

Usage

yt_authenticate(
  client = yt_construct_client(),
  force = FALSE,
  refresh_token = NULL
)

Arguments

client

A YouTube OAuth client created with yt_construct_client().

force

A logical indicating whether to force a refresh of the token.

refresh_token

A refresh token associated with this client. This parameter exists primarily for testing. If you wish to provide a refresh token (for example, for automated processes), we recommend setting a YOUTUBE_REFRESH_TOKEN environment variable.

Value

A YouTube OAuth token, invisibly.

Examples

if (FALSE) { # yt_has_client_envvars() && interactive()
token <- yt_authenticate()
}