Fix: Improve Plex OAuth flow and initialization

This commit is contained in:
Your Name
2026-04-18 01:32:13 +00:00
parent 2c89bf3e18
commit 4d6e36ec24
+7 -1
View File
@@ -8,6 +8,7 @@ const router = Router();
// Plex OAuth configuration
const PLEX_CLIENT_ID = process.env.PLEX_CLIENT_ID || '';
const PLEX_CLIENT_SECRET = process.env.PLEX_CLIENT_SECRET || '';
const PLEX_REDIRECT_URI = process.env.PLEX_REDIRECT_URI || '';
const JWT_SECRET = process.env.JWT_SECRET || 'secret';
@@ -17,7 +18,11 @@ router.get('/plex/url', asyncHandler(async (_req, res) => {
client_id: PLEX_CLIENT_ID,
redirect_uri: PLEX_REDIRECT_URI,
response_type: 'code',
scope: 'openid profile'
scope: 'openid profile',
'X-Plex-Product': 'CoopCoins',
'X-Plex-Client-Identifier': PLEX_CLIENT_ID,
'X-Plex-Device': 'Web Browser',
'X-Plex-Platform': 'Web'
});
const authUrl = `https://app.plex.tv/auth#?${params.toString()}`;
@@ -39,6 +44,7 @@ router.post('/plex/callback', asyncHandler(async (req, res) => {
{
code,
client_id: PLEX_CLIENT_ID,
client_secret: PLEX_CLIENT_SECRET,
grant_type: 'authorization_code'
},
{