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

Support for getting item with OneDrive share link

Open vinismarques opened this issue 2 years ago • 3 comments

I was wondering if anyone could add support for getting drive items using a OneDrive share link.

This page in the documentation gives a little more detail: https://learn.microsoft.com/en-us/graph/api/shares-get?view=graph-rest-1.0&tabs=http

This way we could get the DriveItem and then download it, for example.

vinismarques avatar Sep 20 '22 13:09 vinismarques

@vinismarques Did you get this resolved?

williamhamilton avatar Jul 04 '23 03:07 williamhamilton

Hey @williamhamilton, I did find a workaround for the time being.

Check out this code. It is a library for Robot Framework, but you should be able to easily copy it to your own code, just bear in mind that self.client is an instance of O365.Account and you are good to go.

First, it encodes the shared URL using the function _encode_share_url and then uses a SharedItem class to add support for this new "type", since the original drive.File builds the wrong URL if used with shared items.

Hope this is helpful to you.

vinismarques avatar Jul 04 '23 04:07 vinismarques

@vinismarques Thanks. I will take a look. I want to regularly upload/update files in a SharePoint folder, at the moment I am copying to a local folder which is shared to the user but this needs the user logged in to sync with OneDrive.

williamhamilton avatar Jul 04 '23 04:07 williamhamilton