Fix Plex auth issues by setting header (#43081)

pull/43089/head
jjlawren 2020-11-11 02:40:25 -06:00 committed by GitHub
parent 930866bad5
commit 39cdf61c2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -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"],

View File

@ -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

View File

@ -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