def _init_download_and_get_metadata(
        self,
        temp_dir: str,
        folder_id: Optional[str] = None,
        file_ids: Optional[List[str]] = None,
        folder_path: Optional[str] = None,
        file_paths: Optional[List[str]] = None,
        recursive: bool = False,
        mime_types: Optional[List[str]] = None,
        userprincipalname: Optional[str] = None,
    ) -> List[_OneDriveResourcePayload]:
        """
        Download files from OneDrive based on specified folder or file IDs/Paths.

        Parameters
        ----------
        - temp_dir (str): The temporary directory where files will be downloaded.
        - folder_id (str, optional): The ID of the OneDrive folder to download. If provided, files within the folder are downloaded.
        - file_ids (List[str], optional): List of specific file IDs to download.
        - folder_path (str, optional): The relative path of the OneDrive folder to download. If provided, files within the folder are downloaded.
        - file_paths (List[str], optional): List of specific file paths to download.
        - recursive (bool): Flag indicating whether to download files from subfolders if a folder_id is provided.
        - mime_types(List[str], optional): the mimeTypes you want to allow e.g.: "application/pdf", default is None which loads all files
        - userprincipalname (str): The userprincipalname (normally organization-provided email) whose OneDrive will be accessed. Required for App authentication.

        """
        access_token = self._authenticate_with_msal()
        is_download_from_root = True
        payloads: List[_OneDriveResourcePayload] = []
        # If a folder_id is provided, download files from the folder
        if folder_id:
            is_download_from_root = False
            _payloads = self._connect_download_and_return_metadata(
                access_token,
                local_dir=temp_dir,
                item_id=folder_id,
                include_subfolders=recursive,
                mime_types=mime_types,
                userprincipalname=userprincipalname,
            )
            payloads.extend(_payloads)

        # Download files using the provided file IDs
        if file_ids:
            is_download_from_root = False
            for file_id in file_ids or []:
                item = self._get_items_in_drive_with_maxretries(
                    access_token,
                    file_id,
                    userprincipalname=userprincipalname,
                    isFile=True,
                )
                payload = self._check_approved_mimetype_and_download_file(
                    item,
                    local_dir=temp_dir,
                    mime_types=mime_types,
                    access_token=access_token,
                )
                payloads.append(payload)

        # If a folder_path is provided, download files from the folder
        if folder_path:
            is_download_from_root = False
            payload = self._connect_download_and_return_metadata(
                access_token,
                local_dir=temp_dir,
                item_id=folder_path,
                include_subfolders=recursive,
                mime_types=mime_types,
                userprincipalname=userprincipalname,
                isRelativePath=True,
            )
            payloads.extend(payload)

        # Download files using the provided file paths
        if file_paths:
            is_download_from_root = False
            for file_path in file_paths or []:
                item = self._get_items_in_drive_with_maxretries(
                    access_token,
                    file_path,
                    userprincipalname=userprincipalname,
                    isFile=True,
                    isRelativePath=True,
                )
                payload = self._check_approved_mimetype_and_download_file(
                    item,
                    local_dir=temp_dir,
                    mime_types=mime_types,
                    access_token=access_token,
                )
                payloads.append(payload)

        if is_download_from_root:
            # download files from root folder
            payload = self._connect_download_and_return_metadata(
                access_token,
                local_dir=temp_dir,
                item_id="root",
                include_subfolders=recursive,
                mime_types=mime_types,
                userprincipalname=userprincipalname,
            )
            payloads.extend(payload)

        return payloads

        Download files from OneDrive based on specified folder or file IDs/Paths.

        Parameters
        ----------
        - temp_dir (str): The temporary directory where files will be downloaded.
        - folder_id (str, optional): The ID of the OneDrive folder to download. If provided, files within the folder are downloaded.
        - file_ids (List[str], optional): List of specific file IDs to download.
        - folder_path (str, optional): The relative path of the OneDrive folder to download. If provided, files within the folder are downloaded.
        - file_paths (List[str], optional): List of specific file paths to download.
        - recursive (bool): Flag indicating whether to download files from subfolders if a folder_id is provided.
        - mime_types(List[str], optional): the mimeTypes you want to allow e.g.: "application/pdf", default is None which loads all files
        - userprincipalname (str): The userprincipalname (normally organization-provided email) whose OneDrive will be accessed. Required for App authentication.

        
llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py