We won't be implementing /endpoints endpoint
This commit is contained in:
@@ -5,8 +5,6 @@ from oauthlib.oauth2 import BackendApplicationClient
|
|||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
|
|
||||||
vue_apps_url: str = 'https://apps-vue.ru'
|
vue_apps_url: str = 'https://apps-vue.ru'
|
||||||
default_endpoints: Dict[str, str] = {'access': '/auth', 'refresh': '/refresh',
|
|
||||||
'ping': '/ping', 'endpoints': '/endpoints'}
|
|
||||||
|
|
||||||
|
|
||||||
class ClientAPI:
|
class ClientAPI:
|
||||||
@@ -14,7 +12,7 @@ class ClientAPI:
|
|||||||
client_secret: str
|
client_secret: str
|
||||||
token: Optional[Any]
|
token: Optional[Any]
|
||||||
session: OAuth2Session
|
session: OAuth2Session
|
||||||
endpoints: Dict[str, str]
|
endpoints: Dict[str, str] = {'access': '/auth', 'refresh': '/refresh', 'ping': '/ping'}
|
||||||
|
|
||||||
def build_url(self, endpoint: str) -> str:
|
def build_url(self, endpoint: str) -> str:
|
||||||
return f'{self.vue_apps_url}{self.endpoints[endpoint]}'
|
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
|
:param vue_url: custom URL of Vue Apps API to use
|
||||||
"""
|
"""
|
||||||
self.vue_apps_url = vue_url
|
self.vue_apps_url = vue_url
|
||||||
self.endpoints = default_endpoints
|
|
||||||
|
|
||||||
self.client_id = client_id
|
self.client_id = client_id
|
||||||
self.client_secret = client_secret
|
self.client_secret = client_secret
|
||||||
@@ -41,8 +38,6 @@ class ClientAPI:
|
|||||||
self.token = client_token
|
self.token = client_token
|
||||||
self.setup_flow()
|
self.setup_flow()
|
||||||
|
|
||||||
self.update_endpoints()
|
|
||||||
|
|
||||||
def setup_flow(self):
|
def setup_flow(self):
|
||||||
"""
|
"""
|
||||||
Method sets up the client OAuth2 Session, which will be refreshing tokens for you automatically on requests
|
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
|
self.session.token = self.token
|
||||||
response = self.session.get(self.build_url('ping'))
|
response = self.session.get(self.build_url('ping'))
|
||||||
return response.status_code == 200
|
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()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user