pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
985 stars 665 forks source link

Decode SharePoint Online Sharing links #2172

Open semopz opened 4 years ago

semopz commented 4 years ago

Reporting an Issue or Missing Feature

Issue/Question

Expected behavior

This is more of a question than a suggestion. I'm looking for a CSOM or a REST API that would allows me to decode any kind of a SharePoint sharing link. For example, if you got to a modern UI library to get the link of document, you may be presented with something like this: https://contoso.sharepoint.com/:i:/r/sites/someweb/SiteAssets/cats.jpg?csf=1&e=L9eqe2 This may not look too bad but sharing/anon links are a lot more cryptic.

As a developer, I should be able to decode any links generated by SharePoint (and therefore provided to my app/service/function via a user) in order to get the file's actual path and content.

Actual behavior

If I supply a link that I've obtained from the SP Online Modern UI interface and feed it as a URL param to Get-PnPFile, I will not get a valid SPFile object. I'm using a PowerShell cmdlet as an example here but other PnP libraries or _api calls will result in a failure.

Are there any APIs that would allow me to decode a valid SharePoint links that users may supply to my solution?

Steps to reproduce behavior

  1. Get a link to a file from a SharePoint Online Modern UI library
  2. Try to obtain content or field information using SharePoint APIs with the link obtained in step 1

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

3.10

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

tacklers commented 4 years ago

This has become a big issue with my user community now they realise that a share will overide the 'as designed' permissions.

IT need to be able to advise and revert where necessary

ghost commented 3 years ago

Has there been any movement on this feature request? This is something that many organizations would likely require or benefit from. We're in the process of migrating a large amount of content from Classic sites to Modern pages and many of the older pages reference images via a sharing link rather than the item's URL. We've attempted to leverage invoke-webrequest to capture the 302 redirect with the location header which contains the items real path, but so far that's been unsuccessful.

semopz commented 3 years ago

@flyinaroundpdx I raised this as a question and it seems the lack of activity suggests that there is no way of doing this with public APIs. I'd advise you to look for a similar User Voice feature request and up-voting it or raise one yourself. Or just try to get out of SharePoint development as it is a massive dumpsterfire (that's the path I'm on 🙃)