From 9ec5811b97328a323acebcc006e808bd80b197df Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Thu, 25 Jul 2024 16:46:30 +0200 Subject: [PATCH] fix: correctly map platform names in auth header --- src/utility/JellyfinApi/lib.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utility/JellyfinApi/lib.ts b/src/utility/JellyfinApi/lib.ts index 4e4b9d3b..9de8f9e7 100644 --- a/src/utility/JellyfinApi/lib.ts +++ b/src/utility/JellyfinApi/lib.ts @@ -4,6 +4,15 @@ import { version } from '../../../package.json'; type Credentials = AppState['settings']['credentials']; +/** Map the output of `Platform.OS`, so that Jellyfin can understand it. */ +const deviceMap: Record = { + ios: 'iOS', + android: 'Android', + macos: 'macOS', + web: 'Web', + windows: 'Windows', +}; + /** * This is a convenience function that converts a set of Jellyfin credentials * from the Redux store to a HTTP Header that authenticates the user against the @@ -12,7 +21,7 @@ type Credentials = AppState['settings']['credentials']; function generateConfig(credentials: Credentials): RequestInit { return { headers: { - 'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${Platform.OS}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"` + 'X-Emby-Authorization': `MediaBrowser Client="Fintunes", Device="${deviceMap[Platform.OS]}", DeviceId="${credentials?.device_id}", Version="${version}", Token="${credentials?.access_token}"` } }; }