Force refresh Plex.tv token in settings

* Removes the old PlexPy device and fetches a new token
This commit is contained in:
JonnyWong16 2016-09-29 21:21:07 -07:00
parent 73ac4076ac
commit 0b10e68c60
5 changed files with 115 additions and 20 deletions

View file

@ -3086,8 +3086,8 @@ class WebInterface(object):
if not username and not password:
return None
token = plextv.PlexTV(username=username, password=password)
result = token.get_token()
plex_tv = plextv.PlexTV(username=username, password=password)
result = plex_tv.get_token()
if result:
return result['auth_token']
@ -3095,6 +3095,24 @@ class WebInterface(object):
logger.warn(u"Unable to retrieve Plex.tv token.")
return None
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
def get_plexpy_pms_token(self, username=None, password=None, force=False, **kwargs):
""" Fetch a new Plex.tv token for PlexPy """
if not username and not password:
return None
force = True if force == 'true' else False
plex_tv = plextv.PlexTV(username=username, password=password)
token = plex_tv.get_plexpy_pms_token(force=force)
if token:
return {'result': 'success', 'message': 'Authentication successful.', 'token': token}
else:
return {'result': 'error', 'message': 'Authentication failed.'}
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))