mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Save client identifier from Plex auth for future use (#27951)
* Save client identifier from auth for future use * Bump requirements * Stick with version 1
This commit is contained in:
parent
acc3646ef3
commit
a644182b5e
@ -19,6 +19,7 @@ from homeassistant.util.json import load_json
|
|||||||
from .const import ( # pylint: disable=unused-import
|
from .const import ( # pylint: disable=unused-import
|
||||||
AUTH_CALLBACK_NAME,
|
AUTH_CALLBACK_NAME,
|
||||||
AUTH_CALLBACK_PATH,
|
AUTH_CALLBACK_PATH,
|
||||||
|
CONF_CLIENT_IDENTIFIER,
|
||||||
CONF_SERVER,
|
CONF_SERVER,
|
||||||
CONF_SERVER_IDENTIFIER,
|
CONF_SERVER_IDENTIFIER,
|
||||||
CONF_USE_EPISODE_ART,
|
CONF_USE_EPISODE_ART,
|
||||||
@ -65,6 +66,7 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self.available_servers = None
|
self.available_servers = None
|
||||||
self.plexauth = None
|
self.plexauth = None
|
||||||
self.token = None
|
self.token = None
|
||||||
|
self.client_id = None
|
||||||
|
|
||||||
async def async_step_user(self, user_input=None):
|
async def async_step_user(self, user_input=None):
|
||||||
"""Handle a flow initialized by the user."""
|
"""Handle a flow initialized by the user."""
|
||||||
@ -116,6 +118,8 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
token = server_config.get(CONF_TOKEN)
|
token = server_config.get(CONF_TOKEN)
|
||||||
|
|
||||||
entry_config = {CONF_URL: url}
|
entry_config = {CONF_URL: url}
|
||||||
|
if self.client_id:
|
||||||
|
entry_config[CONF_CLIENT_IDENTIFIER] = self.client_id
|
||||||
if token:
|
if token:
|
||||||
entry_config[CONF_TOKEN] = token
|
entry_config[CONF_TOKEN] = token
|
||||||
if url.startswith("https"):
|
if url.startswith("https"):
|
||||||
@ -216,6 +220,7 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
return self.async_external_step_done(next_step_id="timed_out")
|
return self.async_external_step_done(next_step_id="timed_out")
|
||||||
|
|
||||||
self.token = token
|
self.token = token
|
||||||
|
self.client_id = self.plexauth.client_identifier
|
||||||
return self.async_external_step_done(next_step_id="use_external_token")
|
return self.async_external_step_done(next_step_id="use_external_token")
|
||||||
|
|
||||||
async def async_step_timed_out(self, user_input=None):
|
async def async_step_timed_out(self, user_input=None):
|
||||||
|
@ -21,6 +21,7 @@ PLEX_NEW_MP_SIGNAL = "plex_new_mp_signal.{}"
|
|||||||
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL = "plex_update_mp_signal.{}"
|
PLEX_UPDATE_MEDIA_PLAYER_SIGNAL = "plex_update_mp_signal.{}"
|
||||||
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal.{}"
|
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal.{}"
|
||||||
|
|
||||||
|
CONF_CLIENT_IDENTIFIER = "client_id"
|
||||||
CONF_SERVER = "server"
|
CONF_SERVER = "server"
|
||||||
CONF_SERVER_IDENTIFIER = "server_id"
|
CONF_SERVER_IDENTIFIER = "server_id"
|
||||||
CONF_USE_EPISODE_ART = "use_episode_art"
|
CONF_USE_EPISODE_ART = "use_episode_art"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/plex",
|
"documentation": "https://www.home-assistant.io/integrations/plex",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"plexapi==3.0.6",
|
"plexapi==3.0.6",
|
||||||
"plexauth==0.0.4"
|
"plexauth==0.0.5"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"http"
|
"http"
|
||||||
|
@ -12,6 +12,7 @@ from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL
|
|||||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
CONF_CLIENT_IDENTIFIER,
|
||||||
CONF_SERVER,
|
CONF_SERVER,
|
||||||
CONF_SHOW_ALL_CONTROLS,
|
CONF_SHOW_ALL_CONTROLS,
|
||||||
CONF_USE_EPISODE_ART,
|
CONF_USE_EPISODE_ART,
|
||||||
@ -33,8 +34,6 @@ plexapi.X_PLEX_DEVICE_NAME = X_PLEX_DEVICE_NAME
|
|||||||
plexapi.X_PLEX_PLATFORM = X_PLEX_PLATFORM
|
plexapi.X_PLEX_PLATFORM = X_PLEX_PLATFORM
|
||||||
plexapi.X_PLEX_PRODUCT = X_PLEX_PRODUCT
|
plexapi.X_PLEX_PRODUCT = X_PLEX_PRODUCT
|
||||||
plexapi.X_PLEX_VERSION = X_PLEX_VERSION
|
plexapi.X_PLEX_VERSION = X_PLEX_VERSION
|
||||||
plexapi.myplex.BASE_HEADERS = plexapi.reset_base_headers()
|
|
||||||
plexapi.server.BASE_HEADERS = plexapi.reset_base_headers()
|
|
||||||
|
|
||||||
|
|
||||||
class PlexServer:
|
class PlexServer:
|
||||||
@ -52,6 +51,12 @@ class PlexServer:
|
|||||||
self.options = options
|
self.options = options
|
||||||
self.server_choice = None
|
self.server_choice = None
|
||||||
|
|
||||||
|
# Header conditionally added as it is not available in config entry v1
|
||||||
|
if CONF_CLIENT_IDENTIFIER in server_config:
|
||||||
|
plexapi.X_PLEX_IDENTIFIER = server_config[CONF_CLIENT_IDENTIFIER]
|
||||||
|
plexapi.myplex.BASE_HEADERS = plexapi.reset_base_headers()
|
||||||
|
plexapi.server.BASE_HEADERS = plexapi.reset_base_headers()
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Connect to a Plex server directly, obtaining direct URL if necessary."""
|
"""Connect to a Plex server directly, obtaining direct URL if necessary."""
|
||||||
|
|
||||||
|
@ -971,7 +971,7 @@ pizzapi==0.0.3
|
|||||||
plexapi==3.0.6
|
plexapi==3.0.6
|
||||||
|
|
||||||
# homeassistant.components.plex
|
# homeassistant.components.plex
|
||||||
plexauth==0.0.4
|
plexauth==0.0.5
|
||||||
|
|
||||||
# homeassistant.components.plum_lightpad
|
# homeassistant.components.plum_lightpad
|
||||||
plumlightpad==0.0.11
|
plumlightpad==0.0.11
|
||||||
|
@ -343,7 +343,7 @@ pillow==6.2.0
|
|||||||
plexapi==3.0.6
|
plexapi==3.0.6
|
||||||
|
|
||||||
# homeassistant.components.plex
|
# homeassistant.components.plex
|
||||||
plexauth==0.0.4
|
plexauth==0.0.5
|
||||||
|
|
||||||
# homeassistant.components.mhz19
|
# homeassistant.components.mhz19
|
||||||
# homeassistant.components.serial_pm
|
# homeassistant.components.serial_pm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user