f1tness_parser/backend/app/schemas/auth.py

24 lines
736 B
Python

from typing import Literal, Optional
from pydantic import BaseModel
class LoginRequest(BaseModel):
email: str
password: str
# "web": the refresh token goes only into an httpOnly cookie, script code never sees it.
# "native" (iOS...): it is returned in the body, the app keeps it in the Keychain.
client: Literal["web", "native"] = "native"
class RefreshRequest(BaseModel):
"""Native clients send the refresh token in the body, the web client in the cookie."""
refresh_token: Optional[str] = None
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
expires_in: int # seconds
refresh_token: Optional[str] = None # None for the web client: it is in the cookie