# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from typing import Any

from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class AuthenticateResponseOAuthToken:
    """The OAuth tokens from the identity provider, if applicable."""

    provider: str
    """The OAuth provider used for authentication."""
    refresh_token: str
    """The refresh token from the OAuth provider."""
    access_token: str
    """The access token from the OAuth provider."""
    expires_at: int
    """The timestamp at which the access token expires."""
    scopes: list[str]
    """A list of OAuth scopes for which the access token is authorized."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> AuthenticateResponseOAuthToken:
        """Deserialize from a dictionary."""
        try:
            return cls(
                provider=data["provider"],
                refresh_token=data["refresh_token"],
                access_token=data["access_token"],
                expires_at=data["expires_at"],
                scopes=data["scopes"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AuthenticateResponseOAuthToken", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        result["provider"] = self.provider
        result["refresh_token"] = self.refresh_token
        result["access_token"] = self.access_token
        result["expires_at"] = self.expires_at
        result["scopes"] = self.scopes
        return result
