elastic_enterprise_search/_async/client/__init__.py [115:166]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self,
        *,
        client_id: str,
        client_secret: str,
        redirect_uri: str,
        code: t.Optional[str] = None,
        refresh_token: t.Optional[str] = None,
    ):
        """Exchanges either an authorization code or refresh token for
        an access token via the confidential OAuth flow.

        :param client_id: Client ID as generated when setting up an OAuth application
        :param client_secret: Client secret as generated when setting up an OAuth application
        :param redirect_uri: Location to redirect user once the OAuth process is completed.
            Must match one of the URIs configured in the OAuth application
        :param code: Authorization code as returned by the '/ws/oauth/authorize' endpoint
        :param refresh_token: Refresh token returned at the same time as receiving an access token
        :returns: The HTTP response containing the access_token and refresh_token
            along with other token-related metadata
        """
        values = [client_id, client_secret, redirect_uri]

        # Check that 'code' and 'refresh_token' are mutually exclusive
        if code is None and refresh_token is None:
            raise ValueError(
                "Either the 'code' or 'refresh_token' parameter must be used"
            )
        elif code is not None and refresh_token is not None:
            raise ValueError(
                "'code' and 'refresh_token' parameters are mutually exclusive"
            )
        elif code is not None:
            values.append(code)
            grant_type = "authorization_code"
        else:
            assert refresh_token is not None
            values.append(refresh_token)
            grant_type = "refresh_token"

        if not all(isinstance(value, str) for value in values):
            raise TypeError("All parameters must be of type 'str'")

        params = {
            "grant_type": grant_type,
            "client_id": client_id,
            "client_secret": client_secret,
            "redirect_uri": redirect_uri,
        }
        if code is not None:
            params["code"] = code
        else:
            params["refresh_token"] = refresh_token
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



elastic_enterprise_search/_sync/client/__init__.py [115:166]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        self,
        *,
        client_id: str,
        client_secret: str,
        redirect_uri: str,
        code: t.Optional[str] = None,
        refresh_token: t.Optional[str] = None,
    ):
        """Exchanges either an authorization code or refresh token for
        an access token via the confidential OAuth flow.

        :param client_id: Client ID as generated when setting up an OAuth application
        :param client_secret: Client secret as generated when setting up an OAuth application
        :param redirect_uri: Location to redirect user once the OAuth process is completed.
            Must match one of the URIs configured in the OAuth application
        :param code: Authorization code as returned by the '/ws/oauth/authorize' endpoint
        :param refresh_token: Refresh token returned at the same time as receiving an access token
        :returns: The HTTP response containing the access_token and refresh_token
            along with other token-related metadata
        """
        values = [client_id, client_secret, redirect_uri]

        # Check that 'code' and 'refresh_token' are mutually exclusive
        if code is None and refresh_token is None:
            raise ValueError(
                "Either the 'code' or 'refresh_token' parameter must be used"
            )
        elif code is not None and refresh_token is not None:
            raise ValueError(
                "'code' and 'refresh_token' parameters are mutually exclusive"
            )
        elif code is not None:
            values.append(code)
            grant_type = "authorization_code"
        else:
            assert refresh_token is not None
            values.append(refresh_token)
            grant_type = "refresh_token"

        if not all(isinstance(value, str) for value in values):
            raise TypeError("All parameters must be of type 'str'")

        params = {
            "grant_type": grant_type,
            "client_id": client_id,
            "client_secret": client_secret,
            "redirect_uri": redirect_uri,
        }
        if code is not None:
            params["code"] = code
        else:
            params["refresh_token"] = refresh_token
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



