From 39cdf61c2d44bea66705f211b0e02c92a64063c2 Mon Sep 17 00:00:00 2001 From: jjlawren Date: Wed, 11 Nov 2020 02:40:25 -0600 Subject: [PATCH] Fix Plex auth issues by setting header (#43081) --- homeassistant/components/plex/config_flow.py | 6 ++++-- homeassistant/components/plex/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/plex/config_flow.py b/homeassistant/components/plex/config_flow.py index bdbdc9c6cc9..f177412e7ec 100644 --- a/homeassistant/components/plex/config_flow.py +++ b/homeassistant/components/plex/config_flow.py @@ -289,6 +289,8 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_plex_website_auth(self): """Begin external auth flow on Plex website.""" self.hass.http.register_view(PlexAuthorizationCallbackView) + hass_url = get_url(self.hass) + headers = {"Origin": hass_url} payload = { "X-Plex-Device-Name": X_PLEX_DEVICE_NAME, "X-Plex-Version": X_PLEX_VERSION, @@ -298,9 +300,9 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): "X-Plex-Model": "Plex OAuth", } session = async_get_clientsession(self.hass) - self.plexauth = PlexAuth(payload, session) + self.plexauth = PlexAuth(payload, session, headers) await self.plexauth.initiate_auth() - forward_url = f"{get_url(self.hass)}{AUTH_CALLBACK_PATH}?flow_id={self.flow_id}" + forward_url = f"{hass_url}{AUTH_CALLBACK_PATH}?flow_id={self.flow_id}" auth_url = self.plexauth.auth_url(forward_url) return self.async_external_step(step_id="obtain_token", url=auth_url) diff --git a/homeassistant/components/plex/manifest.json b/homeassistant/components/plex/manifest.json index afb3a2961ef..5bfbc4932ab 100644 --- a/homeassistant/components/plex/manifest.json +++ b/homeassistant/components/plex/manifest.json @@ -5,7 +5,7 @@ "documentation": "https://www.home-assistant.io/integrations/plex", "requirements": [ "plexapi==4.2.0", - "plexauth==0.0.5", + "plexauth==0.0.6", "plexwebsocket==0.0.12" ], "dependencies": ["http"], diff --git a/requirements_all.txt b/requirements_all.txt index 10c7c7e4e2f..e66066e6f4e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1134,7 +1134,7 @@ pizzapi==0.0.3 plexapi==4.2.0 # homeassistant.components.plex -plexauth==0.0.5 +plexauth==0.0.6 # homeassistant.components.plex plexwebsocket==0.0.12 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 42ec5b0c19a..8b843b6a084 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -554,7 +554,7 @@ pillow==7.2.0 plexapi==4.2.0 # homeassistant.components.plex -plexauth==0.0.5 +plexauth==0.0.6 # homeassistant.components.plex plexwebsocket==0.0.12