From d6823bb264b125ce879f1a5f8d5b60f3574fd1e2 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Thu, 29 Jan 2026 13:32:14 +0100 Subject: [PATCH] fix: switch Jellyfin auth to use the `Authorization` header fixes #317 --- .../components/CredentialGenerator.tsx | 2 +- src/utility/JellyfinApi/lib.ts | 21 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/screens/modals/SetJellyfinServer/components/CredentialGenerator.tsx b/src/screens/modals/SetJellyfinServer/components/CredentialGenerator.tsx index 4b4e44b..fde6bfe 100644 --- a/src/screens/modals/SetJellyfinServer/components/CredentialGenerator.tsx +++ b/src/screens/modals/SetJellyfinServer/components/CredentialGenerator.tsx @@ -122,7 +122,7 @@ const CredentialGenerator: React.FC = ({ serverUrl, onCredentialsRetrieve // good const response = await fetch(`${address}/Users/${userId}`, { headers: { - 'X-Emby-Authorization': `MediaBrowser Client="", Device="", DeviceId="", Version="", Token="${accessToken}"` + 'Authorization': `MediaBrowser Client="", Device="", DeviceId="", Version="", Token="${accessToken}"` } }); diff --git a/src/utility/JellyfinApi/lib.ts b/src/utility/JellyfinApi/lib.ts index f0c0e7a..8ee6139 100644 --- a/src/utility/JellyfinApi/lib.ts +++ b/src/utility/JellyfinApi/lib.ts @@ -20,11 +20,22 @@ const deviceMap: Record = { * Jellyfin server. */ function generateConfig(credentials: Credentials): RequestInit { - return { - headers: { - 'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${deviceMap[Platform.OS]}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"` - } - }; + switch (credentials?.type) { + case 'jellyfin': + return { + headers: { + 'Authorization': `MediaBrowser Client="Fintunes", Device="${deviceMap[Platform.OS]}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"` + } + }; + case 'emby': + return { + headers: { + 'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${deviceMap[Platform.OS]}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"` + } + }; + default: + return {}; + } } /**