As per Azure Graph API documentation, request format for sharing a SharePoint document with an expirable link is below format. But it is not working as link is accessible even after the configured time.
{
"recipients": [
{
"email": "ryan@contoso.com"
}
],
"message": "Here's the file that we're collaborating on.",
"requireSignIn": true,
"sendInvitation": true,
"roles": [ "write" ],
"password": "password123",
"expirationDateTime": "2023-10-12T14:00:00.000Z"
}
I've already went through below post, but this is a different API. SharePoint share link still available after expiration date
I agree with @user2250152
expirationDateTime
has no effect on SharePoint share link.
When I ran below request to send sharing invitation, I got response without expirationDateTime
in it:
POST https://graph.microsoft.com/v1.0/sites/{siteId}/drive/items/{itemId}/invite
{
"recipients": [
{
"email": "sri@xxxxxxxx.onmicrosoft.com"
}
],
"message": "Here's the file that we're collaborating on.",
"requireSignIn": true,
"sendInvitation": true,
"roles": [
"write"
],
"password": "password123",
"expirationDateTime": "2023-10-13T05:59:11.716Z"
}
Response:
This automatically sends mail with shared file link to recipient's email address like this:
When user clicks that shared link even after expiration time, it is accessible as below:
Alternatively, you can run below request to delete the permission on shared link after some time:
DELETE https://graph.microsoft.com/v1.0/sites/{siteId}/drive/items/{itemId}/permissions/{permissionId}
Response:
When user tries to access the shared link again now, it will throw Access Denied error as below: