Commit 1d2a13be authored by echel0n's avatar echel0n

Added exception handling for grabbing token endpoint from auth server.

parent 17361b69
...@@ -17,7 +17,6 @@ class API(object): ...@@ -17,7 +17,6 @@ class API(object):
self.api_url = 'https://www.sickrage.ca/api/v3/' self.api_url = 'https://www.sickrage.ca/api/v3/'
self.client_id = sickrage.app.oidc_client_id self.client_id = sickrage.app.oidc_client_id
self.client_secret = sickrage.app.oidc_client_secret self.client_secret = sickrage.app.oidc_client_secret
self.token_url = sickrage.app.oidc_client.well_known['token_endpoint']
@property @property
def session(self): def session(self):
...@@ -61,6 +60,13 @@ class API(object): ...@@ -61,6 +60,13 @@ class API(object):
'scope': value.scope if isinstance(value, OAuth2Token) else value.get('scope') 'scope': value.scope if isinstance(value, OAuth2Token) else value.get('scope')
})) }))
@property
def token_url(self):
try:
return sickrage.app.oidc_client.well_known['token_endpoint']
except requests.exceptions.RequestException:
return "https://auth.sickrage.ca/auth/realms/sickrage/protocol/openid-connect/token"
@property @property
def userinfo(self): def userinfo(self):
return self._request('GET', 'userinfo') return self._request('GET', 'userinfo')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment