'Unable to fetch google drive folder metadata of "shared drive" with public read access using drive api

I am trying to fetch files list for folder id: 1onXpw46omyGlbL5tf0OJdS4i7saXkr40. It is a folder in a "shared drive". It's owner is an organisation, shared link is: https://drive.google.com/drive/folders/1onXpw46omyGlbL5tf0OJdS4i7saXkr40. The code I am using to fetch is

q = "'{0}' in parents".format(folderId)

data = (
            drive.service.files().list(
            q=q,
            pageToken="",
            pageSize=1000,
            fields="nextPageToken, files(id, name, mimeType, size, parents, modifiedTime)",
            supportsAllDrives=True
            )
        .execute()
        )

I am receiving an empty list as output whereas for other "mydrive" links which has "anyone with link can view access" I am receiving list of files and folders correctly.

Please help me resolve this issue



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source