List of all authorized users for file (including shares)

Hi Guys,

I am developing a tool which is analyzing and comparing all documents lying in a nextclouds external storage (/var/www/html/data/…). But the result has to respect the user privacy, so for each user this comparison should only happen based on documents the current user has access to.

My Question is, is there any way to programmatically retrieve all Nextcloud UserIDs that got access to a specific file? I was thinking about using the OCS Share API ( but it seems like it always needs the credentials of each fileowner which I naturally don’t have access to.

If I just go for the filepath (which includes the UserIDs), I would miss out all shared documents and folders.

Any ideas how to tackle this problem?
Greetings Paul