diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index f63c2e2..000c676 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -224,29 +224,7 @@ async function fetchSpotifyToken() { _spSecretCache = null; // force secret re-extraction next time } - // Approach 2: Client Credentials fallback (requires SPOTIFY_CLIENT_ID/SECRET in env) - if (!CONFIG.spotifyClientId || !CONFIG.spotifyClientSecret) { - throw new Error( - 'Spotify-Token nicht abrufbar (TOTP gescheitert). ' + - 'SPOTIFY_CLIENT_ID und SPOTIFY_CLIENT_SECRET setzen als Fallback.' - ); - } - const basic = Buffer.from(`${CONFIG.spotifyClientId}:${CONFIG.spotifyClientSecret}`).toString('base64'); - const r = await _fetchTimeout('https://accounts.spotify.com/api/token', { - method: 'POST', - headers: { 'Authorization': `Basic ${basic}`, 'Content-Type': 'application/x-www-form-urlencoded' }, - body: 'grant_type=client_credentials', - }); - if (!r.ok) { - const errBody = await r.text().catch(() => ''); - throw new Error(`Spotify-Token-Fehler (${r.status}): ${errBody.slice(0, 200)}`); - } - const d = await r.json(); - if (!d.access_token) throw new Error('Kein access_token von Spotify erhalten'); - _spTokenCache = d.access_token; - _spTokenExpiry = Date.now() + (d.expires_in * 1000) - 30000; - console.log('[spotify] token ok (Client Credentials)'); - return _spTokenCache; + throw new Error('Spotify-Token nicht abrufbar (TOTP gescheitert)'); } async function _spApi(path, token) { @@ -370,9 +348,7 @@ app.get('/api/health', (req, res) => { squidQuality: CONFIG.squidQuality, activeJobs: activeDownloads, queueLength: downloadQueue.length, - spotify: { - configured: !!(CONFIG.spotifyClientId && CONFIG.spotifyClientSecret), - }, + spotify: { configured: true }, }); }); diff --git a/src/spotify.js b/src/spotify.js index 68ee4ac..6f85fa4 100644 --- a/src/spotify.js +++ b/src/spotify.js @@ -6,32 +6,13 @@ import { makeGlobalTrackItem } from './components.js'; import { openDlModal } from './ui.js'; // ─── SPOTIFY IMPORTER PAGE ─── -export async function loadSpotifyImporter() { +export function loadSpotifyImporter() { if (!document.getElementById('spotify-link-input')?.value) { const hint = document.getElementById('spotify-importer-hint'); const preview = document.getElementById('spotify-preview'); if (hint) hint.style.display = ''; if (preview) preview.style.display = 'none'; } - - if (S.cfg.backendUrl) { - try { - const h = await fetch(`${S.cfg.backendUrl}/api/health`, { signal: AbortSignal.timeout(5000) }).then(r => r.json()); - if (!h.spotify?.configured) { - const input = document.getElementById('spotify-link-input'); - if (input) { - input.disabled = true; - input.placeholder = 'Spotify-Importer nicht konfiguriert (Server-Setup erforderlich)'; - } - const hint = document.getElementById('spotify-importer-hint'); - if (hint) hint.innerHTML += ` -
- ⚠ Server-Admin muss SPOTIFY_CLIENT_ID und SPOTIFY_CLIENT_SECRET setzen. - Kostenlos unter developer.spotify.com/dashboard. -
`; - } - } catch { /* health check failed — leave UI as-is */ } - } } export function clearSpotifyPreview() { @@ -108,24 +89,6 @@ export async function resolveSpotifyLink() { `; return; } - if (e.message.includes('SPOTIFY_CLIENT_ID') || - e.message.includes('Credentials fehlen') || - e.message.includes('Spotify-Token-Fehler')) { - inner.innerHTML = `
-
Spotify-Importer nicht konfiguriert
-
- Der Server-Admin muss einmalig Spotify-Credentials hinterlegen.

- Schritte:
- 1. developer.spotify.com/dashboard öffnen
- 2. "Create app" — Name beliebig, Redirect URI: http://localhost
- 3. Client ID + Secret als Environment-Variablen setzen:
-   SPOTIFY_CLIENT_ID=...
-   SPOTIFY_CLIENT_SECRET=...
- 4. Backend neu starten -
-
`; - return; - } inner.innerHTML = `
${esc(e.message)}
`; } }