Improve Tidal auth instructions for remote and Docker users

Enhanced the Tidal authentication page to provide clearer, step-by-step instructions for users accessing the app remotely or via Docker. The new flow helps users update the callback URL as needed, improving the authentication experience in non-localhost environments.
This commit is contained in:
Broque Thomas 2026-01-06 20:03:23 -08:00
parent c251edc709
commit ec1d193093

View file

@ -2738,7 +2738,73 @@ def auth_tidal():
print(f"🔗 Redirect URI in URL: {params['redirect_uri']}")
add_activity_item("🔐", "Tidal Auth Started", "Please complete OAuth in browser", "Now")
return f'<h1>🔐 Tidal Authentication</h1><p>Please visit this URL to authenticate:</p><p><a href="{auth_url}" target="_blank">{auth_url}</a></p><p>After authentication, return to the app.</p>'
# Detect if accessing remotely (copied from Spotify auth logic)
host = request.host.split(':')[0]
is_remote = host not in ['127.0.0.1', 'localhost']
is_docker = os.path.exists('/.dockerenv')
# If in Docker and accessing via 127.0.0.1, recommend localhost
if is_docker and host == '127.0.0.1':
host = 'localhost'
if is_remote or is_docker:
# Show instructions for remote/docker access
page_title = "🔐 Tidal Authentication (Remote/Docker)"
step_1_text = "Click the link below to authenticate with Tidal"
return f'''
<html>
<head>
<style>
body {{ font-family: Arial, sans-serif; padding: 20px; max-width: 800px; margin: 0 auto; }}
code {{ background: #f0f0f0; padding: 10px; display: block; margin: 10px 0; }}
.highlight {{ background: #e8f5e9; }}
.copy-btn {{
background: #000000; /* Tidal Black */
color: white;
border: none;
padding: 8px 16px;
cursor: pointer;
border-radius: 4px;
font-size: 14px;
margin-left: 10px;
}}
.copy-btn:hover {{ background: #333333; }}
.copied {{ background: #4CAF50 !important; }}
</style>
</head>
<body>
<h1>{page_title}</h1>
<p><strong>Step 1:</strong> {step_1_text}</p>
<p><a href="{auth_url}" target="_blank" style="font-size: 18px; color: #000000;">{auth_url}</a></p>
<hr>
<p><strong>Step 2:</strong> After authorizing, you'll see a blank page or an error. The URL will look like:</p>
<code>http://127.0.0.1:8888/tidal/callback?code=...</code>
<p><strong>Step 3:</strong> Change <code style="display: inline; background: #ffe6e6; padding: 2px 6px;">127.0.0.1</code> to <code style="display: inline; background: #e8f5e9; padding: 2px 6px;">{host}</code> and press Enter:
<button class="copy-btn" onclick="copyIP()">Copy IP</button>
</p>
<code class="highlight">http://{host}:8888/tidal/callback?code=...</code>
<p>Authentication will then complete!</p>
<script>
function copyIP() {{
navigator.clipboard.writeText('{host}').then(() => {{
const btn = event.target;
btn.textContent = '✓ Copied!';
btn.classList.add('copied');
setTimeout(() => {{
btn.textContent = 'Copy IP';
btn.classList.remove('copied');
}}, 2000);
}});
}}
</script>
</body>
</html>
'''
else:
return f'<h1>🔐 Tidal Authentication</h1><p>Please visit this URL to authenticate:</p><p><a href="{auth_url}" target="_blank">{auth_url}</a></p><p>After authentication, return to the app.</p>'
except Exception as e:
print(f"🔴 Error starting Tidal auth: {e}")