Fix HTTP 401 and authentication endless loop
This commit is contained in:
parent
ae51e43145
commit
753e090cec
4 changed files with 26 additions and 1 deletions
|
@ -474,7 +474,7 @@ def GetPMSStatus(token):
|
||||||
"""
|
"""
|
||||||
answer = {}
|
answer = {}
|
||||||
xml = downloadutils.DownloadUtils().downloadUrl(
|
xml = downloadutils.DownloadUtils().downloadUrl(
|
||||||
"{server}" + '/status/sessions',
|
'{server}/status/sessions',
|
||||||
type="GET",
|
type="GET",
|
||||||
headerOptions={'X-Plex-Token': token})
|
headerOptions={'X-Plex-Token': token})
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
import requests
|
import requests
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
|
|
||||||
|
import xbmcgui
|
||||||
|
|
||||||
from utils import logging, settings, window
|
from utils import logging, settings, window
|
||||||
import clientinfo
|
import clientinfo
|
||||||
|
|
||||||
|
@ -245,6 +247,27 @@ class DownloadUtils():
|
||||||
# No body in the response
|
# No body in the response
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
elif r.status_code == 401:
|
||||||
|
r.encoding = 'utf-8'
|
||||||
|
self.logMsg('HTTP error 401 from PMS. Message received:', -1)
|
||||||
|
self.logMsg(r.text, -1)
|
||||||
|
if '401 Unauthorized' in r.text:
|
||||||
|
# Truly unauthorized
|
||||||
|
self.logMsg('We seem to be truely unauthorized', 0)
|
||||||
|
if window('emby_serverStatus') not in ('401', 'Auth'):
|
||||||
|
# Tell userclient token has been revoked.
|
||||||
|
self.logMsg('Setting emby_serverStatus to 401', 0)
|
||||||
|
window('emby_serverStatus', value="401")
|
||||||
|
xbmcgui.Dialog().notification(
|
||||||
|
self.addonName,
|
||||||
|
"Error connecting: Unauthorized.",
|
||||||
|
xbmcgui.NOTIFICATION_ERROR)
|
||||||
|
return 401
|
||||||
|
else:
|
||||||
|
# there might be other 401 where e.g. PMS is under strain (tbv)
|
||||||
|
self.logMsg('PMS might only be under strain', 0)
|
||||||
|
return 401
|
||||||
|
|
||||||
elif r.status_code in (200, 201):
|
elif r.status_code in (200, 201):
|
||||||
# 200: OK
|
# 200: OK
|
||||||
# 201: Created
|
# 201: Created
|
||||||
|
|
|
@ -253,6 +253,7 @@ class UserClient(threading.Thread):
|
||||||
lang(39023))
|
lang(39023))
|
||||||
xbmc.executebuiltin(
|
xbmc.executebuiltin(
|
||||||
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
'Addon.OpenSettings(plugin.video.plexkodiconnect)')
|
||||||
|
return False
|
||||||
|
|
||||||
# Get /profile/addon_data
|
# Get /profile/addon_data
|
||||||
addondir = xbmc.translatePath(
|
addondir = xbmc.translatePath(
|
||||||
|
|
|
@ -39,6 +39,7 @@ class WebSocket(threading.Thread):
|
||||||
self.logMsg(message, -1)
|
self.logMsg(message, -1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self.logMsg('websocket message received: %s' % message, -1)
|
||||||
# Triage
|
# Triage
|
||||||
typus = message.get('type')
|
typus = message.get('type')
|
||||||
if typus is None:
|
if typus is None:
|
||||||
|
|
Loading…
Reference in a new issue