diff --git a/pyproject.toml b/pyproject.toml index 0917e6e..b2c257f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "HospitalAssistantBackend" -version = "1.2.0" +version = "1.2.1" description = "Backend for Hospital Assistant" readme = "README.md" requires-python = ">=3.13,<3.14" diff --git a/src/clients/esia/api.py b/src/clients/esia/api.py index d729415..a728c6b 100644 --- a/src/clients/esia/api.py +++ b/src/clients/esia/api.py @@ -1,7 +1,7 @@ import uuid from datetime import UTC, datetime from logging import getLogger -from typing import Any +from typing import Any, Literal import jwt from fastapi import status as st @@ -36,10 +36,14 @@ class ESIA_API(AsyncClient): return params - async def access_token(self, code: str): + async def access_token( + self, code: str, platform: Literal['max', 'app'] = 'app' + ): params = { 'grant_type': 'authorization_code', - 'redirect_uri': settings.ESIA_REDIRECT_URI, + 'redirect_uri': settings.ESIA_REDIRECT_URI + if platform == 'app' + else settings.ESIA_MAX_REDIRECT_URI, 'code': code, } signed_params = await self.sign_request(params) @@ -49,6 +53,7 @@ class ESIA_API(AsyncClient): case st.HTTP_200_OK: return s.AccessTokenModel.model_validate(res.json()) case st.HTTP_400_BAD_REQUEST: + self.logger.warning(res.json()) return None case _: