1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
"""YoLink authorization manager."""
import abc
from aiohttp import ClientSession
class YoLinkAuthMgr(metaclass=abc.ABCMeta):
"""YoLink API Authentication Manager."""
def __init__(self, session: ClientSession) -> None:
"""YoLink Auth Manager"""
self._session = session
def client_session(self) -> ClientSession:
"""Get client session."""
return self._session
@abc.abstractmethod
def access_token(self) -> str:
"""Get auth token."""
def http_auth_header(self) -> str:
"""Get auth header."""
return f"Bearer {self.access_token()}"
@abc.abstractmethod
async def check_and_refresh_token(self) -> str:
"""Check and fresh token."""
|