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

Trying to get share link data returns 403 Client Error

Open dion-gdn opened this issue 2 years ago • 0 comments

Hi,

I'm trying to resolve a shared link (organization link) to a file or folder object or at least I want to get the path to the shared object. Here's what I've tried and also the result:

url = '{ shared organization link }'
client.web.get_sharing_link_data(url).execute_query() # this raises 403, error message is in the next code block
client.clear()
Web.get_sharing_link_kind(client, url) # this also raises 403 with the same message as before
client.clear()
client.web.get_file_by_linking_url(url).get().execute_query() # also raises 403 with the same error message
client.clear()
client.web.get_file_by_guest_url(url).get().execute_query() # still 403

Error message:

office365.runtime.client_request_exception.ClientRequestException: ('-2130575251, System.Runtime.InteropServices.COMException', 'The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.', '403 Client Error: FORBIDDEN for url: https://{ tenant }.sharepoint.com/sites/{ site_name }/_api/Web/{ GetSharingLinkData | GetSharingLinkKind | GetFileByLinkingUrl }')

I have searched for the same exception online but found no clue as it seems that it is a generic error message from dotnet or something. Please help me if you know anything. Thank you.

dion-gdn avatar May 30 '23 23:05 dion-gdn