Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
llama-index-readers-microsoft-onedrive
Advanced tools
pip install llama-index-readers-microsoft-onedrive
This loader reads files from:
It supports recursively traversing and downloading files from subfolders and provides capability to download only files with specific mime types. To use this loader, you need to pass in a list of file/folder id or file/folder paths.
To disable: loader.load_data(recursive = False)
You can also filter the files by the mimeType e.g.: mime_types=["application/vnd.openxmlformats-officedocument.wordprocessingml.document"]
OneDriveReader supports following two MSAL authentication:
Microsoft Graph --> Delegated Permission -- > Files.Read.All
You need to create a app registration in Microsoft Entra (formerly Azure Active Directory)
For silent authentication to work, You need to create a client secret as well for the app.
This mode of authnetication is not supported by Microsoft currently for OneDrive Personal, hence this can be used only for OneDrive for Business(Microsoft 365).
API Permission required for registered app:
Microsoft Graph --> Application Permissions -- > Files.Read.All (Grant Admin Consent)
Microsoft Graph --> Application Permissions -- > User.Read.All (Grant Admin Consent)
Note: If you trying to connect to OneDrive Personal you can initialize OneDriveReader with just your clientid and interactive login. Microsoft _doesn't support App authentication for OneDrive Personal currently.
You can extract a folder_id directly from its URL.
For example, the folder_id of https://onedrive.live.com/?id=B5AF52B769DFDE4%216107&cid=0B5AF52B769DFDdRE4
is B5AF52B769DFDE4%216107
.
You can extract a file_id directly from its preview URL.
For example, the file_id of https://onedrive.live.com/?cid=0B5AF52BE769DFDE4&id=B5AF52B769DFDE4%216106&parId=root&o=OneUp
is B5AF52B769DFDE4%216106
.
from llama_index.readers.microsoft_onedrive import OneDriveReader
# User Authentication flow: Replace client id with your own id
loader = OneDriveReader(client_id="82ee706e-2439-47fa-877a-95048ead9318")
# APP Authentication flow: NOT SUPPORTED By Microsoft
#### Get all documents including subfolders.
documents = loader.load_data()
#### Get documents using folder_id , to exclude traversing subfolders explicitly set the recursive flag to False, default is True
documents = loader.load_data(folder_id="folderid", recursive=False)
#### Using file ids
documents = loader.load_data(file_ids=["fileid1", "fileid2"])
https://portal.office.com/onedrive
Note: If you are an organization trying to connect to OneDrive for Business (Part of Microsoft 365), you need to:
The relative pathof subfolder from the root folder(Documents).
For example:
The path of 1st level subfolder with name "drice co" (within root folder) with URL of https://foobar-my.sharepoint.com/personal/godwin_foobar_onmicrosoft_com/_layouts/15/onedrive.aspx?id=/personal/godwin_foobar_onmicrosoft_com/Documents/drice%20co/test
is drice%20co
The path of 2nd level subfolder "test" (within drice co subfolder) with URL of https://foobar-my.sharepoint.com/personal/godwin_foobar_onmicrosoft_com/_layouts/15/onedrive.aspx?id=/personal/godwin_foobar_onmicrosoft_com/Documents/drice%20co/test
is drice%20co/test
The relatve path of files from the root folder(Documents).
For example, the path of file "demo_doc.docx" within test subfolder from previous example with url of https://foobar-my.sharepoint.com/personal/godwin_foobar_onmicrosoft_com/_layouts/15/onedrive.aspx?id=/personal/godwin_foobar_onmicrosoft_com/Documents/drice%20co/test/demo_doc.docx
is drice%20co/test/demo_doc.docx
from llama_index.readers.microsoft_onedrive import OneDriveReader
loader = OneDriveReader(
client_id="82ee706e-2439-47fa-877a-95048ead9318",
tenant_id="02ee706f-2439-47fa-877a-95048ead9318",
client_secret="YOUR_SECRET",
)
#### Get all docx or pdf documents (subfolders included).
documents = loader.load_data(
mime_types=[
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/pdf",
],
userprincipalname="godwin@foobar.onmicrosoft.com",
)
#### Get all documents from a folder of mentioned user's onedrive for business
documents = loader.load_data(
folder_path="subfolder/subfolder2",
userprincipalname="godwin@foobar.onmicrosoft.com",
)
#### Using file paths and userprincipalname(org provided email) of user
documents = loader.load_data(
file_ids=[
"subfolder/subfolder2/fileid1.pdf",
"subfolder/subfolder3/fileid2.docx",
],
userprincipalname="godwin@foobar.onmicrosoft.com",
)
This loader is designed to be used as a way to load data into LlamaIndex.
FAQs
llama-index readers microsoft_onedrive integration
We found that llama-index-readers-microsoft-onedrive demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.