Search code examples
office365office365api

OFFICE 365 API to retrieve external users list from AnyoneWithLink shareable link


Is there any API to get all the external users to whom document is shared via shareable link.

Below is the example

enter image description here


Solution

  • Using below URL with driveId and documentId we can retrieve the permisisons. /drives/{drive-id}/items/{item-id}/permissions

    Under permisison response we can see with link shared with specific people permission objects contains grantedToIdentities field which is list of all specific peoples with whom document is shared as link.

    `

    "grantedTo": null,
      "roles": [
        "write"
      ],
      "id": "0h6842a8-b407-4ytc-bb6f-300cureed649",
      "link": {
        "webUrl": "https://test-my.sharepoint.com/:x:/g/personal/testUser_onmicrosoft_com/kschdjduuhjUUU_atwwoslsXjs4Ya0mW41xwpy",
        "scope": "users",
        "type": "edit"
      },
      "grantedToIdentities": [
        {
          "user": {
            "displayName": "[email protected]",
            "surname": null,
            "userPrincipalName": null,
            "id": null,
            "givenName": null,
            "mail": null,
            "email": "[email protected]"
          }
        }
      ],
      "expirationDateTime": null
    }
    

    `