from dataclasses import dataclass from marshmallow import EXCLUDE from .client import ApiClient from ..config import ATLAS_CLIENT_ID, ATLAS_AUDIENCE, ATLAS_CLIENT_SECRET, ATLAS_GRANT_TYPE @dataclass class AtlasTokenResponse: access_token: str expires_in: int token_type: str class Meta: unknown = EXCLUDE class AtlasClient: http_client: ApiClient def __init__(self, client: ApiClient) -> None: self.http_client = client async def get_authorization_token(self): endpoint = "/oauth/token" payload = { 'audience': ATLAS_AUDIENCE, 'grant_type': ATLAS_GRANT_TYPE, 'client_id': ATLAS_CLIENT_ID, 'client_secret': ATLAS_CLIENT_SECRET } return await self.http_client.post(endpoint, payload=payload, response_type=AtlasTokenResponse)