Skip to content

add_user_pool_client_secret async

add_user_pool_client_secret(
    user_pool_id: UserPoolIdType,
    client_id: ClientIdType,
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
    client_secret: Optional[ClientSecretType] = None,
) -> AddUserPoolClientSecretResponse

Creates a new client secret for an existing confidential user pool app client. Supports up to 2 active secrets per app client for zero-downtime credential rotation workflows.

Parameters:

  • user_pool_id (UserPoolIdType) –

    The ID of the user pool that contains the app client.

  • client_id (ClientIdType) –

    The ID of the app client for which you want to create a new secret.

  • client_secret (Optional[ClientSecretType], default: None ) –

    The client secret value you want to use. If you don't provide this parameter, Amazon Cognito generates a secure secret for you.

Raises:

  • AccessDeniedException –

    This exception is thrown when you don't have sufficient permissions to perform the requested operation.

  • InternalServerException –

    This exception is thrown when Amazon Cognito encounters an internal server error.

  • InvalidParameterException –

    This exception is thrown when the Amazon Cognito service encounters an invalid parameter.

  • LimitExceededException –

    This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.

  • ResourceNotFoundException –

    This exception is thrown when the Amazon Cognito service can't find the requested resource.

  • TooManyRequestsException –

    This exception is thrown when the user has made too many requests for a given operation.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_cognito_identity_provider/_services/async_cognito_identity_provider.py
async def add_user_pool_client_secret(
    self,
    user_pool_id: "capo_cognito_identity_provider.types.user_pool_id_type.UserPoolIdType",
    client_id: "capo_cognito_identity_provider.types.client_id_type.ClientIdType",
    *,
    config_overrides: Optional[AsyncCognitoIdentityProviderClientConfig] = None,
    client_secret: Optional[
        "capo_cognito_identity_provider.types.client_secret_type.ClientSecretType"
    ] = None,
) -> "capo_cognito_identity_provider.types.add_user_pool_client_secret_response.AddUserPoolClientSecretResponse":
    """<p>Creates a new client secret for an existing confidential user pool app client. Supports up to 2 active secrets per app client for zero-downtime credential rotation workflows.</p>

    Args:
        user_pool_id: <p>The ID of the user pool that contains the app client.</p>
        client_id: <p>The ID of the app client for which you want to create a new secret.</p>
        client_secret: <p>The client secret value you want to use. If you don't provide this parameter, Amazon Cognito generates a secure secret for you.</p>

    Raises:
        capo_cognito_identity_provider.errors.access_denied_exception.AccessDeniedException: <p>This exception is thrown when you don't have sufficient permissions to perform the requested operation.</p>
        capo_cognito_identity_provider.errors.internal_server_exception.InternalServerException: <p>This exception is thrown when Amazon Cognito encounters an internal server error.</p>
        capo_cognito_identity_provider.errors.invalid_parameter_exception.InvalidParameterException: <p>This exception is thrown when the Amazon Cognito service encounters an invalid parameter.</p>
        capo_cognito_identity_provider.errors.limit_exceeded_exception.LimitExceededException: <p>This exception is thrown when a user exceeds the limit for a requested Amazon Web Services resource.</p>
        capo_cognito_identity_provider.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when the Amazon Cognito service can't find the requested resource.</p>
        capo_cognito_identity_provider.errors.too_many_requests_exception.TooManyRequestsException: <p>This exception is thrown when the user has made too many requests for a given operation.</p>
        capo_cognito_identity_provider.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cognito_identity_provider.types.add_user_pool_client_secret_request.AddUserPoolClientSecretRequest]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity_provider.types.add_user_pool_client_secret_response.AddUserPoolClientSecretResponse"
    ]:
        import capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.add_user_pool_client_secret

        (
            output,
            http_response,
        ) = await capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.add_user_pool_client_secret.async_add_user_pool_client_secret(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cognito_identity_provider.types.add_user_pool_client_secret_request.AddUserPoolClientSecretRequest",
    ) -> dict[str, Any]:
        import capo_cognito_identity_provider.types.add_user_pool_client_secret_request

        return capo_cognito_identity_provider.types.add_user_pool_client_secret_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_cognito_identity_provider.types.add_user_pool_client_secret_response.AddUserPoolClientSecretResponse",
    ) -> dict[str, Any]:
        import capo_cognito_identity_provider.types.add_user_pool_client_secret_response

        return capo_cognito_identity_provider.types.add_user_pool_client_secret_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "AddUserPoolClientSecret",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cognito_identity_provider.types.add_user_pool_client_secret_request.AddUserPoolClientSecretRequest = {
        "user_pool_id": user_pool_id,
        "client_id": client_id,
    }
    if client_secret is not None:
        input_["client_secret"] = client_secret

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output