Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Onedrive - get files (shared with user/followed by user)

Open ssmails opened this issue 1 year ago • 3 comments

Hello @vgrem @GitSumito , came across the issue https://github.com/vgrem/Office365-REST-Python-Client/issues/654

question on how to get the user_assertion for the below ? msal_app.acquire_token_on_behalf_of(user_assertion=id_token,scopes=["https://graph.microsoft.com/.default"])

Per the below link, it seems it needs user interaction to get it. Is that correct? https://github.com/Azure-Samples/ms-identity-python-on-behalf-of

Wondering if any way to get the files shared/followed by user for one drive, without user interaction ? Is this possible using the ConfidentialClientApplication with MSAL to get the token and use with these examples ?

app = msal.ConfidentialClientApplication(clientID, authority=authority, client_credential={"thumbprint": thumbprint, "private_key": cert}) 
    result = app.acquire_token_for_client(scopes=scope)

Can these examples be updated to support the use case of an app accessing users drive items / shared items - via msal ConfidentialClientApplication, if that is possible ? https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/onedrive/drives/list_followed_items.py https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/onedrive/drives/list_shared_with_me.py

ssmails avatar Feb 24 '24 23:02 ssmails

When I try the ClientCredential Flow as documented https://github.com/vgrem/Office365-REST-Python-Client/tree/master?tab=readme-ov-file#working-with-onedrive-and-sharepoint-v2-apis ,

and use it for the example https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/onedrive/drives/list_followed_items.py

I get an error - Is this use case supported with the client credential flow ? Since I plan to have this functionality in a daemon web application, I assume I need to use the client credential flow.

office365.runtime.client_request_exception.ClientRequestException: ('BadRequest', '/me request is only valid with delegated authentication flow.', '400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/me/drive/following')

If not, How do we configure the delegated authentication flow to use with this ? I am using a MS Azure App with attached permissions.

Screenshot 2024-02-25 at 12 06 47 PM

ssmails avatar Feb 25 '24 20:02 ssmails

@vgrem Can you kindly help on this. Thanks.

ssmails avatar Feb 25 '24 20:02 ssmails