Module genshin.models.auth.cookie

Cookie-related models

Classes

class AppLoginResult (**data: Any)

App login cookies.

Returned by client.login_with_app_password.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class AppLoginResult(CookieLoginResult):
    """App login cookies.

    Returned by `client.login_with_app_password`.
    """

    stoken: str
    ltuid_v2: str
    ltmid_v2: str
    account_id_v2: str
    account_mid_v2: str

Ancestors

Class variables

var account_id_v2 : str
var account_mid_v2 : str
var ltmid_v2 : str
var ltuid_v2 : str
var model_computed_fields
var model_config
var model_fields
var stoken : str

Inherited members

class CNWebLoginResult (**data: Any)

Web login cookies.

Returned by client.cn_login_with_password.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class CNWebLoginResult(CookieLoginResult):
    """Web login cookies.

    Returned by `client.cn_login_with_password`.
    """

    cookie_token_v2: str
    account_mid_v2: str
    account_id_v2: str
    ltoken_v2: str
    ltmid_v2: str
    ltuid_v2: str

Ancestors

Class variables

var account_id_v2 : str
var account_mid_v2 : str
var cookie_token_v2 : str
var ltmid_v2 : str
var ltoken_v2 : str
var ltuid_v2 : str
var model_computed_fields
var model_config
var model_fields

Inherited members

class CookieLoginResult (**data: Any)

Base model for cookie login result.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class CookieLoginResult(pydantic.BaseModel):
    """Base model for cookie login result."""

    def to_str(self) -> str:
        """Convert the login cookies to a string."""
        return "; ".join(f"{key}={value}" for key, value in self.model_dump().items())

    def to_dict(self) -> dict[str, str]:
        """Convert the login cookies to a dictionary."""
        return self.model_dump()

Ancestors

  • pydantic.main.BaseModel

Subclasses

Class variables

var model_computed_fields
var model_config
var model_fields

Methods

def to_dict(self) ‑> dict[str, str]

Convert the login cookies to a dictionary.

def to_str(self) ‑> str

Convert the login cookies to a string.

class DeviceGrantResult (**data: Any)

Cookies returned by the device grant endpoint.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class DeviceGrantResult(pydantic.BaseModel):
    """Cookies returned by the device grant endpoint."""

    game_token: str
    login_ticket: typing.Optional[str] = None

    @pydantic.model_validator(mode="before")
    def _str_to_none(cls, data: dict[str, typing.Union[str, None]]) -> dict[str, typing.Union[str, None]]:
        """Convert empty strings to `None`."""
        for key in data:
            if data[key] == "" or data[key] == "None":
                data[key] = None
        return data

Ancestors

  • pydantic.main.BaseModel

Class variables

var game_token : str
var login_ticket : Optional[str]
var model_computed_fields
var model_config
var model_fields
class GameLoginResult (**data: Any)

Game login result.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class GameLoginResult(pydantic.BaseModel):
    """Game login result."""

    combo_id: str
    open_id: str
    combo_token: str
    heartbeat: bool
    account_type: int

Ancestors

  • pydantic.main.BaseModel

Class variables

var account_type : int
var combo_id : str
var combo_token : str
var heartbeat : bool
var model_computed_fields
var model_config
var model_fields
var open_id : str
class MobileLoginResult (**data: Any)

Mobile number login cookies.

Returned by client.login_with_mobile_number.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class MobileLoginResult(CookieLoginResult):
    """Mobile number login cookies.

    Returned by `client.login_with_mobile_number`.
    """

    cookie_token_v2: str
    account_mid_v2: str
    account_id_v2: str
    ltoken_v2: str
    ltmid_v2: str

Ancestors

Class variables

var account_id_v2 : str
var account_mid_v2 : str
var cookie_token_v2 : str
var ltmid_v2 : str
var ltoken_v2 : str
var model_computed_fields
var model_config
var model_fields

Inherited members

class QRLoginResult (**data: Any)

QR code login cookies.

Returned by client.login_with_qrcode.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class QRLoginResult(CookieLoginResult):
    """QR code login cookies.

    Returned by `client.login_with_qrcode`.
    """

    cookie_token_v2: str
    account_mid_v2: str
    account_id_v2: str
    ltoken_v2: str
    ltmid_v2: str
    ltuid_v2: str

Ancestors

Class variables

var account_id_v2 : str
var account_mid_v2 : str
var cookie_token_v2 : str
var ltmid_v2 : str
var ltoken_v2 : str
var ltuid_v2 : str
var model_computed_fields
var model_config
var model_fields

Inherited members

class StokenResult (**data: Any)

Result of fetching stoken with fetch_stoken_by_game_token.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class StokenResult(pydantic.BaseModel):
    """Result of fetching `stoken` with `fetch_stoken_by_game_token`."""

    aid: str
    mid: str
    token: str

    @pydantic.model_validator(mode="before")
    def _transform_result(cls, values: dict[str, typing.Any]) -> dict[str, typing.Any]:
        return {
            "aid": values["user_info"]["aid"],
            "mid": values["user_info"]["mid"],
            "token": values["token"]["token"],
        }

Ancestors

  • pydantic.main.BaseModel

Class variables

var aid : str
var mid : str
var model_computed_fields
var model_config
var model_fields
var token : str
class WebLoginResult (**data: Any)

Web login cookies.

Returned by client.login_with_password.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Expand source code
class WebLoginResult(CookieLoginResult):
    """Web login cookies.

    Returned by `client.login_with_password`.
    """

    cookie_token_v2: str
    account_mid_v2: str
    account_id_v2: str
    ltoken_v2: str
    ltmid_v2: str
    ltuid_v2: str

Ancestors

Class variables

var account_id_v2 : str
var account_mid_v2 : str
var cookie_token_v2 : str
var ltmid_v2 : str
var ltoken_v2 : str
var ltuid_v2 : str
var model_computed_fields
var model_config
var model_fields

Inherited members