Files
plezy/lib/services/jellyfin_auth_header.dart
T
edde746 d80a1ed15a feat: report real device identity to media servers
Resolve platform, hardware model, and friendly device name once via a
shared DeviceIdentityService and send them to both backends: Plex gets
a real X-Plex-Platform plus X-Plex-Device/X-Plex-Device-Name (shown as
Player in dashboards/Tautulli), Jellyfin gets the device name in the
MediaBrowser auth header. Transcode and live-TV decision requests keep
their pinned platform names, which Plex validates server-side.

close #1270
2026-07-05 01:22:20 +02:00

25 lines
933 B
Dart

/// Build the `MediaBrowser` Authorization header value the way the Jellyfin
/// SDK formats it. Used at auth time and on every authenticated request so
/// the server sees a consistent client identity.
///
/// Values are quote-stripped: the header grammar has no escape for `"`, so a
/// device name like `My "cool" TV` would otherwise corrupt every field after
/// it.
String buildJellyfinAuthHeader({
required String clientName,
required String clientVersion,
required String deviceName,
required String deviceId,
String? accessToken,
}) {
String quoted(String value) => '"${value.replaceAll('"', '')}"';
final parts = <String>[
'Client=${quoted(clientName)}',
'Device=${quoted(deviceName)}',
'DeviceId=${quoted(deviceId)}',
'Version=${quoted(clientVersion)}',
if (accessToken != null && accessToken.isNotEmpty) 'Token=${quoted(accessToken)}',
];
return 'MediaBrowser ${parts.join(', ')}';
}