I am developing a tool for my company that allows people to share files from our network with clients in a very automated way to make sharing documents easier for everyone. However, I have run into a bit of a problem when it comes to sharing the documents themselves.
Currently, when someone shares a document, it uses the "ShareDocument" extension from https://github.com/pnp/pnpframework. My implementation of it is as follows (email is just a variable containing the provided email address of the client):
result = context.Web.ShareDocument(site,
email,
ExternalSharingDocumentOption.View,
false,
"");
This works perfectly and overall, my software is done and in a working state. However, there is one thing that really bothers me and will definitely cause confusion. When sharing with some clients who are considered guests, they don't get the normal external sharing link. Instead, they get given direct access. The issue with this is that for me to provide the links to the user to share, I need to provide two (external share link and direct access link) and specify which client works for each link. For example:
I want all emails to be shared like this:
But some users who Sharepoint considers guests are being shared like this:
Does anyone know how I can force Sharepoint to share users through the "Links Giving Access" method instead of with the "Direct Access" method. It can be done manually but that makes the development of this tool to be pointless. I am happy to modify the PnPFramework extensions if necessary, I am just unsure where to even start.
I have tried making a custom people picker input which copies the people picker input for an email that does get given the correct link and just replaced the email in it with the "guest" user's email but that made no difference.