python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

`drive.get_items()` do not return `File` type `DriveItem`s, just `Folder` type ones

Open MattSom opened this issue 3 years ago • 2 comments

As the title says. I only get the folders returned from the root, the files are omitted. In child folders the files are returned as well. Is this intended?

MattSom avatar Oct 23 '22 21:10 MattSom

can you share the code? what's drive there?

alejcas avatar Oct 27 '22 08:10 alejcas

credentials = (
    app.config.get("SP_CLIENT_ID"),
    app.config.get("SP_CLIENT_SECRET"),
)

token_backend = FileSystemTokenBackend(
    token_path=app.config.get("SP_TOKEN_PATH"),
    token_filename=app.config.get("SP_TOKEN_FILE"),
)

account = Account(
    credentials=credentials,
    auth_flow_type="credentials",
    token_backend=token_backend,
    tenant_id=app.config.get("SP_TENANT_ID"),
)

site = account.sharepoint().get_site(app.config.get("SP_SITE_ID"))

drive = site.list_document_libraries()[0]

drive.get_items()

The last line returns:

[Folder: copies,
 Folder: copytest,
 Folder: url,
 Folder: vta,
 Folder: vta_copy]

But actually opening the sharepoint drive I can see that the root folder has tons of different files next to these folders. So only Folder subtyped DriveItems are returned.

MattSom avatar Oct 28 '22 08:10 MattSom