Authentication Setup and Management
May 8, 2026 · View on GitHub
This document covers all aspects of authentication in Youtarr, including initial setup, configuration options, troubleshooting, and security best practices.
Table of Contents
- Overview
- Initial Setup
- Authentication Methods
- API Keys
- Session Management
- Password Management
- Plex OAuth Integration
- Security Best Practices
- Troubleshooting
Overview
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.
Key Features
- 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
Initial Setup
Method 1: Web UI Setup with One-Time Token
On first launch, Youtarr generates a one-time setup token and surfaces it through two channels: your container logs and a file in your data volume. You can complete setup from localhost, your trusted LAN, a VPN, or an SSH tunnel.
-
Retrieve the setup token. Either:
- From container logs:
docker logs youtarr(look for the "Youtarr initial setup required" log entry; the token-bearing entry is emitted atLOG_LEVEL=info), or - From the data volume: read
config/setup-tokenon the host (mounted from the container's/app/config/setup-token). The file is written with mode0600, so if your container runs as a UID that does not match your host user (for example, the container runs as root or asYOUTARR_UID=1000while you log in as a different user), the read will fail with "Permission denied". Usesudo cat /path/to/youtarr/config/setup-token, or fall back to the container-logs path above.
- From container logs:
-
Open Youtarr in a browser, e.g.
http://localhost:3087orhttp://<your-LAN-IP>:3087. -
Complete the setup wizard:
- Paste the setup token (64 hex characters)
- Enter desired username (1-32 characters)
- Enter password (8-64 characters)
- Confirm password
-
The token is consumed on success. Credentials are saved to
config/config.json.
Knowledge of the token requires either Docker access (for the logs) or filesystem access to the data volume (for the file), both of which already imply admin status on the host. The token survives container restarts while setup is incomplete, so you have time to fetch it.
If you wipe or recreate the config/ volume, Youtarr loses the saved credentials and setup token state; run initial setup again on the next boot.
Plain HTTP is intended for localhost and private LAN/VPN access only. Do not expose Youtarr setup or login directly to the internet over HTTP; put it behind HTTPS and normal network controls first.
Treat startup logs as sensitive while setup is incomplete. If you ship container logs to Loki, Splunk, CloudWatch, or another external system, redact or drop the setupToken field/log entry until the one-time setup token has been consumed. When LOG_LEVEL=warn, Youtarr logs setup guidance without the token; use config/setup-token to retrieve the token in that mode.
Method 2: Environment Variables (Headless/Automated)
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 1 character 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.
Method 3: Interactive Headless Setup
Using the start script:
./start.sh --headless-auth
- Prompts for username and password
- Saves to
.envas AUTH_PRESET variables - Starts container with configured credentials
Authentication Methods
Local Authentication
How It Works
- 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
Configuration Fields
{
"username": "admin",
"passwordHash": "\$2b\$10$..."
}
Platform Authentication (AUTH_ENABLED=false)
For deployments behind external authentication or not exposed to the internet:
-
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!
API Keys
API Keys provide persistent authentication for external integrations like bookmarklets, mobile shortcuts, and automation tools.
Key Features
- 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
Current Limitations
- API keys can only download individual videos
- Playlists, channels, and batch operations require the web UI
- Maximum of 20 active API keys per instance
Creating API Keys
- 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!
Using API Keys
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"}'
Security Best Practices
- 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
API Key Management
Via Web UI
- View all keys in Configuration → API Keys & External Access
- Delete keys by clicking the trash icon
- See last usage time for each key
Via Database (Advanced)
# 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.
Session Management
Session Configuration
- 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
Session Security
- 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)
Manual Session Management
View Active Sessions
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;
"
Clear All Sessions (Force Re-login)
docker exec youtarr-db mysql -u root -p123qweasd youtarr -e "
DELETE FROM Sessions;
"
Password Management
Changing Password via UI
- Log in to Youtarr
- Navigate to Configuration
- Click "Change Password"
- Enter current password
- Enter new password (8-64 characters)
- Confirm new password
- Save changes
Reset Forgotten Password if locked out of Youtarr
Option 1: Environment Variables
-
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
Option 2: Direct Config Edit
-
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 -
Open Youtarr and set new credentials with the one-time setup token from the container logs or
config/setup-token
Remote Access for Initial Setup
SSH Port Forwarding
SSH port forwarding is no longer required for security reasons (the localhost gate has been removed). It remains useful as a way to retrieve the setup token over a secure channel if you don't want to enable HTTPS for your Youtarr instance yet.
From Windows:
# PowerShell or Command Prompt
ssh -L 3087:localhost:3087 username@server-ip
# Open http://localhost:3087 in browser
From Linux/Mac:
ssh -L 3087:localhost:3087 username@server-ip
# Open http://localhost:3087 in browser
This creates a secure tunnel for initial setup.
Plex OAuth Integration
Purpose
Plex OAuth is used to obtain API tokens for Plex integration, not for Youtarr authentication.
Setup Process
- 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
Manual Token Retrieval
If OAuth fails, get token manually:
- Visit Plex Token Guide
- Follow instructions to get X-Plex-Token
- Enter token in Configuration page
- Save changes
Token Management
Revoke Token
# Stop Youtarr
./stop.sh
# Clear token from config
# Edit config/config.json, set: "plexApiKey": ""
# Restart
./start.sh
Security Best Practices
Strong Passwords
- Minimum 8 characters (enforced)
- Use mix of upper/lowercase, numbers, symbols
- Avoid dictionary words
- Consider using password manager
Environment Security
-
Protect .env file:
chmod 600 .env -
Protect config directory:
chmod 700 config chmod 600 config/config.json
Network Security
-
Keep HTTP local:
- Plain HTTP is acceptable for localhost, a private LAN, VPN, or SSH tunnel
- Do not port-forward Youtarr directly to the internet over HTTP
-
Use HTTPS with reverse proxy for external access:
- 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
-
Proxy trust:
- Youtarr keeps the historical
TRUST_PROXY=truedefault for compatibility with existing reverse-proxy installs - Youtarr's own rate-limit, session, and setup audit IPs use the direct peer IP until
TRUST_PROXYis explicitly configured - Set
TRUST_PROXY=falsewhen exposing the app directly without a reverse proxy - Set
TRUST_PROXYto a specific hop count or trusted subnet when your reverse proxy setup needs forwarded client IPs
- Youtarr keeps the historical
Authentication Hardening
- Change default credentials immediately
- Use unique username (not "admin")
- Enable fail2ban for brute force protection
- Monitor access logs:
docker logs youtarr | grep "Login"
Troubleshooting
Cannot Find the Setup Token
Problem: First-time setup wizard asks for a token and you don't know where to find it.
Solutions:
- Container logs:
docker logs youtarr | grep -A5 "initial setup required". The token-bearing setup log entry is emitted atLOG_LEVEL=infoon every startup until setup completes. - Data volume: the token is also written to
config/setup-token(mode 0600) in your data volume. From the host:cat /path/to/youtarr/config/setup-token. If you see "Permission denied", the container is running as a UID that does not match your host user; usesudo cat ...or retrieve the token from the container logs (option 1 above) instead. - Lost before setup is complete? Stop Youtarr, delete
config/setup-token, restart. A new token will be generated and logged. - Already completed setup and need to reset? Stop Youtarr, remove
usernameandpasswordHashfromconfig/config.json, restart, then complete setup again with the newly generated token. - Headless without log access? Use the env-var path instead: set
AUTH_PRESET_USERNAMEandAUTH_PRESET_PASSWORDin.env(see Method 2 above).
Invalid Credentials Error
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 username
Session Expired
Symptoms:
- "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
Authentication Loop
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;