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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class OAuthCredentialsResponse(UniversalBaseModel):
    """
    OAuth credentials response for admin endpoints.

    SECURITY: This response contains sensitive OAuth tokens and should only
    be returned to authenticated admin services.
    """

    connection_id: str = pydantic.Field()
    """
    External connection ID
    """

    status: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connection status (ACTIVE, EXPIRED, INITIATED)
    """

    app_name: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connected app (github, googledrive, etc.)
    """

    auth_scheme: typing.Optional[str] = pydantic.Field(default=None)
    """
    Auth scheme (OAUTH2, API_KEY, BASIC, etc.)
    """

    credentials: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    OAuth credentials: access_token, refresh_token, token_type, scope, expires_in
    """

    account_email: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connected account email
    """

    account_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Account ID on the external service
    """

    entity_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Entity ID (freddy_user_xxx)
    """

    auth_config_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    Auth config ID (ac_xxx)
    """

    is_managed: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether using platform-managed credentials
    """

    base_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    Base API URL (e.g. https://www.googleapis.com/drive/v3)
    """

    test_request_endpoint: typing.Optional[str] = pydantic.Field(default=None)
    """
    URL to test connection validity
    """

    callback_url: typing.Optional[str] = pydantic.Field(default=None)
    """
    OAuth callback URL used during authorization
    """

    id_token: typing.Optional[str] = pydantic.Field(default=None)
    """
    OpenID Connect ID token (Google, etc.)
    """

    code_verifier: typing.Optional[str] = pydantic.Field(default=None)
    """
    PKCE code verifier
    """

    extra_headers: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Additional headers for API requests
    """

    query_params: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Additional query parameters
    """

    extra_data: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
    """
    Provider-specific extra data
    """

    expires_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    Token expiration timestamp
    """

    created_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connection creation timestamp
    """

    updated_at: typing.Optional[str] = pydantic.Field(default=None)
    """
    Connection last update timestamp
    """

    status_reason: typing.Optional[str] = pydantic.Field(default=None)
    """
    Reason for current status
    """

    is_disabled: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether connection is disabled
    """

    is_redacted: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether credentials are redacted
    """

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

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