Share via

Anonymous sharing link opens fine but user-specific edit link fails with Access Denied in same browser session

Prajwal K Divate 0 Reputation points
2026-05-20T12:51:42.94+00:00

Hi everyone,

I'm building an application that uses Microsoft Graph API to generate two different types of sharing links for two different files on the same SharePoint site. The setup is working fine in isolation, but I'm running into a weird issue when both links are opened sequentially in the same browser session.

Here is what my app does:

  1. Creates an anonymous (scope: "anonymous") edit link for File A using the createLink API
  2. Creates a user-specific (scope: "users") edit link for File B, granted to a particular email (user@example.com)

The API calls are succeeding and I'm getting valid 200/201 responses for both. The anonymous link works fine. But here is the problem, once the user opens the anonymous link in a browser, and then tries to open the user-specific edit link in the same browser session, they get the "You can't access this site – You don't have permission to access this item" error screen from Microsoft. See screenshot below:

User's image

If I open the user-specific link first (before the anonymous one), it works perfectly. If I open it in a fresh browser / incognito window, it also works. So the issue is clearly happening because of the anonymous session that gets established when File A's link is opened.

For reference, here are the API calls I'm making:

For the anonymous link (File A):

POST https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}/createLink


{

  "type": "edit",

  "scope": "anonymous",

  "retainInheritedPermissions": false

}
Microsoft 365 and Office | SharePoint | Development
0 comments No comments

1 answer

Sort by: Most helpful
  1. Gabriel-N 17,785 Reputation points Microsoft External Staff Moderator
    2026-05-20T14:08:33.2566667+00:00

    Hello @Prajwal K Divate

    Based on my research, when a user opens an anonymous sharing link (scope: "anonymous"), SharePoint establishes an anonymous session in the browser and stores this context using cookies. Any subsequent requests in the same browser session continue to operate under this anonymous context.

    When the user then tries to open a user-specific link (scope: "users"), SharePoint expects an authenticated identity that matches the user the link was granted to. However, the browser is still using the anonymous session, creating a mismatch. This results in the “You don’t have permission to access this item” (or “You can’t access this site”) error.

    This behavior is consistent with SharePoint’s session-identity handling: access fails when the current session context does not match the account the link was granted to.

    As practical workarounds, you may consider:

    • Open the anonymous link in a separate browser context (new window, incognito/private mode, or different browser/profile).
    • Open the user-specific link first, then the anonymous one (the reverse order avoids the conflict).
    • Ensure users are fully authenticated (signed in with the correct account) before opening the user-specific link.
    • Avoid mixing anonymous and user-specific links in the same user flow if possible.

    I hope this clarifies the behavior.


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.