Фикс авторизации ЕСИА Макс
All checks were successful
Build And Push / publish (push) Successful in 3m50s
All checks were successful
Build And Push / publish (push) Successful in 3m50s
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "HospitalAssistantBackend"
|
name = "HospitalAssistantBackend"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
description = "Backend for Hospital Assistant"
|
description = "Backend for Hospital Assistant"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13,<3.14"
|
requires-python = ">=3.13,<3.14"
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import uuid
|
import uuid
|
||||||
from datetime import UTC, datetime
|
from datetime import UTC, datetime
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from typing import Any
|
from typing import Any, Literal
|
||||||
|
|
||||||
import jwt
|
import jwt
|
||||||
from fastapi import status as st
|
from fastapi import status as st
|
||||||
@ -36,10 +36,14 @@ class ESIA_API(AsyncClient):
|
|||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
async def access_token(self, code: str):
|
async def access_token(
|
||||||
|
self, code: str, platform: Literal['max', 'app'] = 'app'
|
||||||
|
):
|
||||||
params = {
|
params = {
|
||||||
'grant_type': 'authorization_code',
|
'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,
|
'code': code,
|
||||||
}
|
}
|
||||||
signed_params = await self.sign_request(params)
|
signed_params = await self.sign_request(params)
|
||||||
@ -49,6 +53,7 @@ class ESIA_API(AsyncClient):
|
|||||||
case st.HTTP_200_OK:
|
case st.HTTP_200_OK:
|
||||||
return s.AccessTokenModel.model_validate(res.json())
|
return s.AccessTokenModel.model_validate(res.json())
|
||||||
case st.HTTP_400_BAD_REQUEST:
|
case st.HTTP_400_BAD_REQUEST:
|
||||||
|
self.logger.warning(res.json())
|
||||||
return None
|
return None
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
|
|||||||
Reference in New Issue
Block a user