Source code for scapi.oauth.models
from datetime import datetime, timedelta
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, field_validator
[docs]
class OAuthModel(BaseModel):
"""Base model for OAuth response data."""
pass
[docs]
class TokenResponse(OAuthModel):
"""Base token response."""
token_type: str
access_token: str
expires_in: datetime
[docs]
@field_validator("expires_in", mode="before")
@classmethod
def parse_expires_in(cls, expires_in: str):
try:
seconds = int(expires_in)
return datetime.now() + timedelta(seconds=seconds)
except Exception:
return None
[docs]
class AppToken(TokenResponse):
"""Application access token."""
pass
[docs]
class UserToken(TokenResponse):
"""User access and refresh token."""
refresh_token: str
[docs]
class UserInfo(OAuthModel):
"""EXBO account information."""
id: int
uuid: UUID
login: str
display_login: Optional[str]
distributor: str
distributor_id: Optional[str]