mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 01:22:19 +03:00
companion: Move start_frontier_auth() above login()
The former will be used by the latter, so this makes more sense when reading the code. In general I'm going to ensure there are two sections to this Session class: 1. Frontier Auth code. 2. CAPI query code. Yes, ideally I'd split it into two classes. But that kind of refactoring isn't for *this* branch. I just want things straight in my head for the "make CAPI queries run in a thread" changes.
This commit is contained in:
parent
81b5d015fd
commit
c01438f77e
16
companion.py
16
companion.py
@ -476,6 +476,14 @@ class Session(object):
|
||||
self.auth: Optional[Auth] = None
|
||||
self.retrying = False # Avoid infinite loop when successful auth / unsuccessful query
|
||||
|
||||
def start_frontier_auth(self, access_token: str) -> None:
|
||||
"""Start an oAuth2 session."""
|
||||
logger.debug('Starting session')
|
||||
self.session = requests.Session()
|
||||
self.session.headers['Authorization'] = f'Bearer {access_token}'
|
||||
self.session.headers['User-Agent'] = USER_AGENT
|
||||
self.state = Session.STATE_OK
|
||||
|
||||
def login(self, cmdr: str = None, is_beta: Union[None, bool] = None) -> bool:
|
||||
"""
|
||||
Attempt oAuth2 login.
|
||||
@ -545,14 +553,6 @@ class Session(object):
|
||||
self.auth = None
|
||||
raise # Bad thing happened
|
||||
|
||||
def start_frontier_auth(self, access_token: str) -> None:
|
||||
"""Start an oAuth2 session."""
|
||||
logger.debug('Starting session')
|
||||
self.session = requests.Session()
|
||||
self.session.headers['Authorization'] = f'Bearer {access_token}'
|
||||
self.session.headers['User-Agent'] = USER_AGENT
|
||||
self.state = Session.STATE_OK
|
||||
|
||||
def query(self, endpoint: str) -> CAPIData: # noqa: CCR001, C901
|
||||
"""Perform a query against the specified CAPI endpoint."""
|
||||
logger.trace_if('capi.query', f'Performing query for endpoint "{endpoint}"')
|
||||
|
Loading…
x
Reference in New Issue
Block a user