This document covers all aspects of authentication in Youtarr, including initial setup, configuration options, troubleshooting, and security best practices.
- Overview
- Initial Setup
- Authentication Methods
- API Keys
- Session Management
- Password Management
- Plex OAuth Integration
- Security Best Practices
- Troubleshooting
Youtarr implements a secure authentication system to protect your instance from unauthorized access. Authentication is required by default and can be configured through multiple methods.
- Local username/password authentication
- Bcrypt password hashing
- Session-based authentication with 7-day expiry
- API Keys for external integrations (bookmarklets, mobile shortcuts, automation)
- Plex OAuth for API token retrieval
- Optional authentication bypass for platform deployments
On first launch, Youtarr requires authentication setup from localhost for security:
-
Access Youtarr from the same machine:
http://localhost:3087 -
Complete the setup wizard:
- Enter desired username (3-32 characters)
- Enter password (8-64 characters)
- Confirm password
-
Credentials are saved to
config/config.json
For remote or automated deployments:
IMPORTANT: If AUTH_PRESET_USERNAME and AUTH_PRESET_PASSWORD do not meet minimum length requirements they will be ignored!
-
Add to
.envfile:AUTH_PRESET_USERNAME=admin # Min 3 characters AUTH_PRESET_PASSWORD=your-secure-password # Min 8 characters
-
Start Youtarr:
./start.shordocker compose up -d -
Credentials are automatically configured
Note: Environment variables override existing credentials on each restart.
Using the start script:
./start.sh --headless-auth- Prompts for username and password
- Saves to
.envas AUTH_PRESET variables - Starts container with configured credentials
- Username and password stored in
config/config.json - Password hashed using bcrypt (10 rounds)
- Session created upon successful login
- Token stored in browser
localStorage(authToken) and attached to subsequent API calls via thex-access-tokenheader
{
"username": "admin",
"passwordHash": "$2b$10$..."
}For deployments behind external authentication or not exposed to the internet:
API Keys provide persistent authentication for external integrations like bookmarklets, mobile shortcuts, and automation tools.
- Persistent: No expiration (unlike session tokens)
- Scoped: Limited to single video downloads only
- Secure: SHA-256 hashed, stored securely
- Rate Limited: Configurable requests per minute
- Revocable: Can be deleted instantly if compromised
- API keys can only download individual videos
- Playlists, channels, and batch operations require the web UI
- Maximum of 20 active API keys per instance
- Navigate to Configuration in the web UI
- Scroll to API Keys & External Access
- Click Create Key
- Enter a descriptive name (e.g., "iPhone Shortcut", "Bookmarklet")
- Important: Copy and save the key immediately - it will not be shown again!
Include the API key in the x-api-key header:
curl -X POST https://your-server.com/api/videos/download \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"url": "https://www.youtube.com/watch?v=VIDEO_ID"}'- Use HTTPS: API keys are transmitted in headers; use HTTPS to protect them
- Descriptive Names: Name keys by purpose (e.g., "Work Laptop", "iPhone") for easy identification
- Monitor Usage: Check "Last Used" to identify suspicious or unused keys
- Rotate If Compromised: Delete and recreate keys if you suspect exposure
- Don't Share Keys: Each user/device should have its own key
- View all keys in Configuration → API Keys & External Access
- Delete keys by clicking the trash icon
- See last usage time for each key
# List active API keys
docker exec youtarr-db mysql -u root -p123qweasd youtarr -e "
SELECT id, name, key_prefix, created_at, last_used_at
FROM ApiKeys
WHERE is_active = 1;
"
# Revoke a key by ID
docker exec youtarr-db mysql -u root -p123qweasd youtarr -e "
UPDATE ApiKeys SET is_active = 0 WHERE id = 1;
"For detailed API documentation and examples (bookmarklets, mobile shortcuts, Python, cURL, etc.), see API Integration Guide.
-
Set in
.env:AUTH_ENABLED=false
-
Youtarr bypasses internal authentication, no auth will be required to access Youtarr.
Warning: Only disable when using:
- VPN access
- Reverse proxy with authentication
- Platform auth (Cloudflare Access, Authelia, etc.)
- Never expose to internet without protection!
- Duration: 7 days
- Storage: Database table
Sessions - Browser storage: Token persisted as
authTokeninlocalStorage - Client header: Token forwarded on each API request via
x-access-token
- Sessions expire after 7 days
- Automatic cleanup of expired sessions (daily at 3 AM)
- Password changes do not automatically revoke existing sessions—use the Sessions UI or the SQL commands below to force a logout
- Multiple concurrent sessions per user are supported (each browser/device maintains its own token)
docker exec youtarr-db mysql -u root -p123qweasd youtarr -e "
SELECT id, session_token, username, expires_at, is_active
FROM Sessions
WHERE expires_at > NOW()
AND is_active = 1;
"docker exec youtarr-db mysql -u root -p123qweasd youtarr -e "
DELETE FROM Sessions;
"- Log in to Youtarr
- Navigate to Configuration
- Click "Change Password"
- Enter current password
- Enter new password (8-64 characters)
- Confirm new password
- Save changes
-
Stop Youtarr:
./stop.shordocker compose down -
Edit
.env:AUTH_PRESET_USERNAME=admin AUTH_PRESET_PASSWORD=new-password
-
Restart:
./start.shordocker compose up -d -
Log in with new credentials, they will be saved to
config/config.json -
(Optional) Remove from
.envafter login and restart Youtarr to allow changing credentials through web UI
-
Stop Youtarr:
./stop.shordocker compose down -
Edit
config/config.json:- Delete
usernameandpasswordHashlines- Ensure that your .json file is valid, the last item in the json config cannot have a trailing comma.
- Delete
-
Restart:
./start.shordocker compose up -d -
Access from localhost to set new credentials
From Windows:
# PowerShell or Command Prompt
ssh -L 3087:localhost:3087 username@server-ip
# Open http://localhost:3087 in browserFrom Linux/Mac:
ssh -L 3087:localhost:3087 username@server-ip
# Open http://localhost:3087 in browserThis creates a secure tunnel for initial setup.
Plex OAuth is used to obtain API tokens for Plex integration, not for Youtarr authentication.
- Navigate to Configuration page
- Click "Get Key" next to Plex API Key field
- Redirected to Plex authentication
- Log in with Plex account (must be server admin)
- Authorize Youtarr
- Token automatically populated
- Save configuration
If OAuth fails, get token manually:
- Visit Plex Token Guide
- Follow instructions to get X-Plex-Token
- Enter token in Configuration page
- Save changes
# Stop Youtarr
./stop.sh
# Clear token from config
# Edit config/config.json, set: "plexApiKey": ""
# Restart
./start.sh- Minimum 8 characters (enforced)
- Use mix of upper/lowercase, numbers, symbols
- Avoid dictionary words
- Consider using password manager
-
Protect .env file:
chmod 600 .env
-
Protect config directory:
chmod 700 config chmod 600 config/config.json
-
Use HTTPS with reverse proxy:
- Nginx/Caddy/Traefik with SSL
- Let's Encrypt certificates
-
Firewall rules:
# Allow only local network iptables -A INPUT -p tcp --dport 3087 -s 192.168.0.0/16 -j ACCEPT iptables -A INPUT -p tcp --dport 3087 -j DROP -
VPN Access:
- Use WireGuard/OpenVPN for remote access
- Avoid exposing to internet directly
- Change default credentials immediately
- Use unique username (not "admin")
- Enable fail2ban for brute force protection
- Monitor access logs:
docker logs youtarr | grep "Login"
Problem: "Initial setup can only be performed from localhost" error
Solutions:
- Use SSH port forwarding (see above)
- Use environment variables for headless setup
- Access from Docker host machine directly
Causes:
- Incorrect username or password
- Caps Lock enabled
- Leading/trailing spaces in credentials
Debug:
# Check if credentials exist
docker exec youtarr cat /app/config/config.json | grep usernameSymptoms:
- "Invalid or expired token" error
- Redirected to login page
Solutions:
- Log in again (normal after 7 days)
- Clear the
authTokenentry (Site Data / Local Storage) for the Youtarr origin if the browser continues to reuse an expired token - Check system time synchronization
Problem: Repeatedly redirected to login
Causes:
- Stale
authTokencached in browser storage - Reverse proxy misconfiguration
- Session storage full
Solutions:
- Clear the
authTokenvalue from browser storage (or choose "Log out" to request a new session) - Check reverse proxy headers:
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr;