Skip to main content

Authentication Methods

Overview

Many video platforms require authentication to access content, whether for premium videos, private content, or to bypass rate limiting. yt-dlp provides multiple authentication methods to handle these scenarios securely and efficiently.

The most convenient method is extracting cookies directly from your browser:

# Extract from Chrome
yt-dlp --cookies-from-browser chrome "URL"

# Extract from Firefox
yt-dlp --cookies-from-browser firefox "URL"

# Extract from Safari (macOS)
yt-dlp --cookies-from-browser safari "URL"

# Extract from Edge
yt-dlp --cookies-from-browser edge "URL"

Browser Profiles and Containers

For specific browser profiles or Firefox containers:

# Specific Chrome profile
yt-dlp --cookies-from-browser "chrome:Profile 1" "URL"

# Firefox container
yt-dlp --cookies-from-browser "firefox::YouTube Container" "URL"

# Default profile explicitly
yt-dlp --cookies-from-browser "chrome:Default" "URL"

Supported Browsers

  • Chrome and Chromium-based browsers
  • Firefox and derivatives
  • Safari (macOS only)
  • Edge (Windows)
  • Opera
  • Brave
  • Vivaldi

Netscape Format

Save cookies in Netscape format for manual management:

# Use cookie file
yt-dlp --cookies cookies.txt "URL"

# Export cookies from browser extensions
# Then use the exported file
yt-dlp --cookies exported_cookies.txt "URL"
# Netscape HTTP Cookie File
.youtube.com TRUE / FALSE 1234567890 session_token abc123def456
.youtube.com TRUE / TRUE 1234567890 secure_token xyz789uvw012

Username and Password Authentication

Direct Login

For sites supporting username/password authentication:

# Interactive password prompt
yt-dlp -u username "URL"

# Specify password (not recommended for scripts)
yt-dlp -u username -p password "URL"

# Two-factor authentication
yt-dlp -u username -p password --2fa 123456 "URL"

Video-Specific Passwords

Some videos have individual passwords:

# Video password
yt-dlp --video-password SECRET "URL"

# Combined with account login
yt-dlp -u username -p password --video-password SECRET "URL"

.netrc Authentication

Automatic Credential Storage

Use .netrc file for secure, automatic authentication:

# Create .netrc file
touch ~/.netrc
chmod 600 ~/.netrc

~/.netrc content:

machine youtube login username@example.com password mypassword
machine twitch login twitchuser password twitchpass
machine vimeo login vimeouser password vimeopass

Using .netrc

# Enable .netrc authentication
yt-dlp --netrc "URL"

# Specify .netrc location
yt-dlp --netrc-location /path/to/.netrc "URL"

# Use custom command for credentials
yt-dlp --netrc-cmd 'gpg --decrypt ~/.authinfo.gpg' "URL"

Platform-Specific Authentication

YouTube

# OAuth login (most reliable)
yt-dlp --username oauth --password '' "URL"

# Browser cookies (recommended)
yt-dlp --cookies-from-browser chrome "URL"

# Handle age-restricted content
yt-dlp --cookies-from-browser chrome "AGE_RESTRICTED_URL"

Twitch

# Twitch requires cookies for most content
yt-dlp --cookies-from-browser firefox "TWITCH_URL"

# Or use .netrc
yt-dlp --netrc "TWITCH_URL"

Adobe Pass (Cable Provider)

# List available providers
yt-dlp --ap-list-mso

# Use specific provider
yt-dlp --ap-mso Comcast --ap-username user --ap-password pass "URL"

Certificate-Based Authentication

Client Certificates

For enterprise or specialized authentication:

# Client certificate file
yt-dlp --client-certificate /path/to/cert.pem "URL"

# Separate certificate and key files
yt-dlp --client-certificate /path/to/cert.pem \
--client-certificate-key /path/to/key.pem "URL"

# Encrypted key with password
yt-dlp --client-certificate /path/to/cert.pem \
--client-certificate-key /path/to/key.pem \
--client-certificate-password keypass "URL"

Authentication Configuration

Configuration File Setup

Store authentication settings in configuration files:

~/.config/yt-dlp/config:

# Default to browser cookies
--cookies-from-browser chrome

# Fallback to .netrc
--netrc

# Handle geo-restrictions
--geo-bypass

Environment Variables

# Set default authentication method
export YTDLP_COOKIES_FROM_BROWSER="chrome"

# Use in scripts
yt-dlp "URL" # Automatically uses Chrome cookies