It appears that you are experiencing inconsistencies with the /me/drive/sharedWithMe endpoint when using the ROPC (Resource Owner Password Credentials) flow. Here are some points to consider regarding your situation:
- Behavioral Differences: The behavior of the
/me/drive/sharedWithMeendpoint may vary based on the authentication method used. ROPC does not provide the same context as an interactive login, which could lead to differences in the items returned. The Graph Explorer and OneDrive UI may utilize additional session information or caching mechanisms that are not available in ROPC. - Permissions: While you have the
User.ReadandFiles.ReadWrite.Allpermissions, it is important to note that certain permissions may be required to access specific shared items. Although the documentation suggests that additional permissions should not be necessary, changes in the API or underlying data structures could affect this behavior. - Caching and Indexing: The results from the Graph API can indeed be influenced by caching and indexing. The OneDrive UI and Graph Explorer might have access to cached data or metadata that is not reflected in API calls made via ROPC, potentially leading to discrepancies in the number of items returned.
- Transient Issues: Since you mentioned that this issue has appeared intermittently, it is possible that there are transient issues with the Graph API or the underlying services that may affect the results returned. Monitoring for patterns or specific conditions when the issue arises could provide further insights.
- Consideration for Additional Scopes: While your security team is cautious about adding
Sites.Read.All, it may be worth discussing the implications of this permission in the context of your application's functionality. If the shared items are stored in a way that requires this permission, it may be necessary to revisit this decision.
In summary, the differences in behavior you are observing could stem from the nature of ROPC authentication, potential caching mechanisms, and the specific permissions granted to your application. It may be beneficial to test with different authentication methods or to consult the Microsoft Graph documentation for any recent changes that could impact the API's behavior.
References: