mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2024-12-23 01:20:12 +00:00
Added re-authentication after expiry to jf_api
This commit is contained in:
parent
5b767da91f
commit
3499843878
@ -36,15 +36,21 @@ class Jellyfin:
|
|||||||
"X-Emby-Authorization": self.auth
|
"X-Emby-Authorization": self.auth
|
||||||
}
|
}
|
||||||
def getUsers(self, username="all", id="all", public=True):
|
def getUsers(self, username="all", id="all", public=True):
|
||||||
if public:
|
if public is True:
|
||||||
response = requests.get(self.server+"/emby/Users/Public").json()
|
response = requests.get(self.server+"/emby/Users/Public").json()
|
||||||
else:
|
elif public is False and hasattr(self, 'username') and hasattr(self, 'password'):
|
||||||
response = requests.get(self.server+"/emby/Users",
|
response = requests.get(self.server+"/emby/Users",
|
||||||
headers=self.header,
|
headers=self.header,
|
||||||
params={'Username': self.username,
|
params={'Username': self.username,
|
||||||
'Pw': self.password})
|
'Pw': self.password})
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
response = response.json()
|
response = response.json()
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.authenticate(self.username, self.password)
|
||||||
|
return self.getUsers(username, id, public)
|
||||||
|
except self.AuthenticationError:
|
||||||
|
raise self.AuthenticationRequiredError
|
||||||
else:
|
else:
|
||||||
raise self.AuthenticationRequiredError
|
raise self.AuthenticationRequiredError
|
||||||
if username == "all" and id == "all":
|
if username == "all" and id == "all":
|
||||||
@ -99,6 +105,10 @@ class Jellyfin:
|
|||||||
params={'Name': username,
|
params={'Name': username,
|
||||||
'Password': password})
|
'Password': password})
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
|
if hasattr(self, 'username') and hasattr(self, 'password'):
|
||||||
|
self.authenticate(self.username, self.password)
|
||||||
|
return self.newUser(username, password)
|
||||||
|
else:
|
||||||
raise self.AuthenticationRequiredError
|
raise self.AuthenticationRequiredError
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -68,7 +68,10 @@ auth = HTTPBasicAuth()
|
|||||||
|
|
||||||
accounts = {}
|
accounts = {}
|
||||||
|
|
||||||
if not config.getboolean('ui', 'jellyfin_login'):
|
if config.getboolean('ui', 'jellyfin_login'):
|
||||||
|
log.debug('Using jellyfin for admin authentication')
|
||||||
|
else:
|
||||||
|
log.debug('Using configured login details for admin authentication')
|
||||||
accounts['adminAccount'] = Account(config['ui']['username'],
|
accounts['adminAccount'] = Account(config['ui']['username'],
|
||||||
config['ui']['password'])
|
config['ui']['password'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user