feat(): yandex oauth client

This commit is contained in:
doas root
2025-11-18 23:01:42 +03:00
parent 3bea2c2f75
commit beeca57c1e
4 changed files with 130 additions and 4 deletions
@@ -1,11 +1,8 @@
from typing import TYPE_CHECKING, override
from typing import override
from template_project.application.auth_identity.entity import AuthMethod
from template_project.application.common.errors import ApplicationError, to_error
if TYPE_CHECKING:
pass
@to_error
class UserAlreadyExistsError(ApplicationError):
@@ -0,0 +1,42 @@
from abc import abstractmethod
from typing import Protocol
from template_project.application.common.data_structure import to_data_structure
from template_project.application.common.errors import ApplicationError, to_error
@to_data_structure
class OAuthTokenResponse:
access_token: str
expires_in: int | None = None
@to_data_structure
class OAuthUserInfo:
user_id: str
email: str | None = None
display_name: str | None = None
first_name: str | None = None
last_name: str | None = None
avatar_url: str | None = None
phone: str | None = None
@to_error
class OAuthExchangeCodeError(ApplicationError):
pass
@to_error
class OAuthLoadUserInfoError(ApplicationError):
pass
class OAuthClient(Protocol):
@abstractmethod
async def exchange_code(self, code: str) -> OAuthTokenResponse:
raise NotImplementedError
@abstractmethod
async def load_user_info(self, access_token: str) -> OAuthUserInfo:
raise NotImplementedError