From 648b346cbe5a941c7e1ec4ddfb276fb0e27ed502 Mon Sep 17 00:00:00 2001 From: Jakob Ankarhem Date: Sat, 12 Mar 2022 06:03:19 +0100 Subject: [PATCH] fix(plex): use unique client identifier (#2602) * fix(plex): use unique client identifier As noted by SwiftPanda each client needs a unique identifier https://discord.com/channels/783137440809746482/793885156569514046/950083089575583824 * fix(typo): fix character casing Co-authored-by: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Co-authored-by: TheCatLady <52870424+TheCatLady@users.noreply.github.com> --- src/utils/plex.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/plex.ts b/src/utils/plex.ts index 0fa86bc74..b34e9733c 100644 --- a/src/utils/plex.ts +++ b/src/utils/plex.ts @@ -34,12 +34,24 @@ class PlexOAuth { 'Window is not defined. Are you calling this in the browser?' ); } + + let clientId = localStorage.getItem('overseerrPlexClientId'); + if (!clientId) { + const uuid = crypto.randomUUID && crypto.randomUUID(); + if (!uuid) { + throw new Error('Could not generate client ID'); + } + + localStorage.setItem('overseerrPlexClientId', uuid); + clientId = uuid; + } + const browser = Bowser.getParser(window.navigator.userAgent); this.plexHeaders = { Accept: 'application/json', 'X-Plex-Product': 'Overseerr', 'X-Plex-Version': '2.0', - 'X-Plex-Client-Identifier': '7f9de3ba-e12b-11ea-87d0-0242ac130003', + 'X-Plex-Client-Identifier': clientId, 'X-Plex-Model': 'Plex OAuth', 'X-Plex-Platform': browser.getOSName(), 'X-Plex-Platform-Version': browser.getOSVersion(),