# This file was auto-generated by Fern from our API Definition.

from ...core.unchecked_base_model import UncheckedBaseModel
import typing
from .http_receiver_o_auth_style import HttpReceiverOAuthStyle
import pydantic
from .http_receiver_o_auth_credential import HttpReceiverOAuthCredential
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class HttpReceiverOAuthConfig(UncheckedBaseModel):
    """
    OAuth 2.0 client credentials flow (RFC 6749) for service-to-service authentication.
    """

    auth_style: typing.Optional[HttpReceiverOAuthStyle] = pydantic.Field(default=None)
    """
    How to send client credentials when requesting OAuth access tokens:
    
    - `in_header`: Send client credentials via HTTP Basic authentication. This is the **recommended and most secure method**, used by most modern OAuth 2.0 providers.
    - `in_params`: Send client credentials URL-encoded in the request body as form parameters. Required by some legacy OAuth servers and specific provider implementations. Consult your OAuth provider documentation for details.
    """

    credential: HttpReceiverOAuthCredential
    endpoint_params: typing.Optional[typing.Dict[str, str]] = pydantic.Field(
        default=None
    )
    """
    Additional parameters to include in OAuth token request
    """

    scopes: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    OAuth2 scopes to request when fetching access token
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(
            extra="allow"
        )  # type: ignore # Pydantic v2
    else:

        class Config:
            smart_union = True
            extra = pydantic.Extra.allow
