knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette addresses the most common issues users encounter when setting up and using the tuber package.
Cause: The YouTube Data API v3 is not enabled in your Google Cloud project.
Solution: 1. Go to Google Cloud Console 2. Select your project (or create a new one) 3. Enable the YouTube Data API v3: https://console.cloud.google.com/marketplace/product/google/youtube.googleapis.com 4. Wait 2-5 minutes for the API to be fully activated 5. Try your request again
Cause: Your OAuth scope or API key doesn't have the required permissions.
Solution:
- For OAuth: Delete .httr-oauth file and re-authenticate with yt_oauth()
- For API keys: Ensure your API key has YouTube Data API permissions
- Some operations (like accessing private videos) require OAuth authentication
Complete Setup Instructions:
1. Go to Google Cloud Console
2. Create a new project or select existing one
3. Enable YouTube Data API v3
4. Go to Credentials
5. Click "Create Credentials" > "OAuth client ID"
6. Choose "Desktop application"
7. Note the Client ID and Client Secret
8. Use: yt_oauth("your_client_id", "your_client_secret")
Issue: Browser doesn't open or redirect fails
Solutions:
- Use out-of-band authentication: yt_oauth(app_id, app_secret, use_oob = TRUE)
- For server environments, copy the authorization code manually
- Ensure your OAuth app is configured for "Desktop application"
Cause: You've exceeded your daily API quota (default: 10,000 units).
Solutions: - Wait until quota resets (daily at Pacific Time midnight) - Request quota increase in Google Cloud Console - Use batch operations to reduce quota usage - Cache results to avoid repeated API calls
Cause: Too many requests in a short time period.
Solution: Add delays between requests:
# Add small delays between requests Sys.sleep(0.1) # 100ms delay
Cause: Caption download requires video ownership.
Solution: You can only download captions from videos you own using OAuth authentication.
Cause: YouTube API has built-in limits and some comments may be hidden.
Solutions: - YouTube limits total searchable results (~500 for search, varies for comments) - Some comments may be filtered by YouTube's spam detection - Private or deleted comments won't appear in results
Cause: Channel usernames may have changed to custom URLs.
Solution: Use channel IDs instead of usernames when possible:
# Instead of username get_channel_stats(channel_id = "UC_x5XG1OV2P6uZZ5FSM9Ttw") # Instead of get_channel_stats(username = "oldusername")
If you continue to experience issues:
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.