We won't be implementing /endpoints endpoint

This commit is contained in:
havlong
2022-12-20 18:16:35 +03:00
parent 6697a7b80e
commit 65a78ebc1b

View File

@@ -5,8 +5,6 @@ from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
vue_apps_url: str = 'https://apps-vue.ru'
default_endpoints: Dict[str, str] = {'access': '/auth', 'refresh': '/refresh',
'ping': '/ping', 'endpoints': '/endpoints'}
class ClientAPI:
@@ -14,7 +12,7 @@ class ClientAPI:
client_secret: str
token: Optional[Any]
session: OAuth2Session
endpoints: Dict[str, str]
endpoints: Dict[str, str] = {'access': '/auth', 'refresh': '/refresh', 'ping': '/ping'}
def build_url(self, endpoint: str) -> str:
return f'{self.vue_apps_url}{self.endpoints[endpoint]}'
@@ -29,7 +27,6 @@ class ClientAPI:
:param vue_url: custom URL of Vue Apps API to use
"""
self.vue_apps_url = vue_url
self.endpoints = default_endpoints
self.client_id = client_id
self.client_secret = client_secret
@@ -41,8 +38,6 @@ class ClientAPI:
self.token = client_token
self.setup_flow()
self.update_endpoints()
def setup_flow(self):
"""
Method sets up the client OAuth2 Session, which will be refreshing tokens for you automatically on requests
@@ -73,9 +68,3 @@ class ClientAPI:
self.session.token = self.token
response = self.session.get(self.build_url('ping'))
return response.status_code == 200
def update_endpoints(self):
"""
Refresh endpoints object used to determine path in queries
"""
self.endpoints = self.session.get(self.build_url('endpoints')).json()