python-o365
python-o365 copied to clipboard
Support for getting item with OneDrive share link
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 Did you get this resolved?
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 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.