def serialize_object(obj):
    """
    Serialize the provided object.

    We look for "to_dict" and "to_serializable_dict" methods. If none of those methods is
    available, we fall back to "repr(obj)".

    :rtype: ``str``
    """
    # Try to serialize the object
    if getattr(obj, "to_dict", None):
        value = obj.to_dict()
    elif getattr(obj, "to_serializable_dict", None):
        value = obj.to_serializable_dict(mask_secrets=True)
    else:
        value = repr(obj)

    return value