Skip to content

Latest commit

 

History

History
241 lines (184 loc) · 7.95 KB

permission-grant.md

File metadata and controls

241 lines (184 loc) · 7.95 KB
author title description ms.localizationpriority ms.subservice doc_type
kevklam
Grant permission
Grant a list of users access to use the specified link
medium
sharepoint
apiPageType

permission: grant

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Grant users access to a link represented by a permission.

[!INCLUDE national-cloud-support]

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

[!INCLUDE permissions-table]

HTTP request

POST /shares/{encoded-sharing-url}/permission/grant

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.

Request body

In the request body, provide a JSON object with the following parameters.

{
  "recipients": [
    { "@odata.type": "microsoft.graph.driveRecipient" }
  ],
  "roles": [ "read | write"]
}
Parameter Type Description
recipients Collection(driveRecipient) A collection of recipients who will receive access.
roles Collection(String) If the link is an "existing access" link, specifies roles to be granted to the users. Otherwise must match the role of the link.

For a list of available roles, see roles property values.

Response

If successful, this method returns a 200 OK response code and a permission collection in the response body.

A permission representing the updated link will always be returned in the result set on success. The updated link can be identified by the presence of a 'link' facet containing the 'scope' property. In some cases it may be possible that the updated link has a different URL than the original link, in which case the new URL should be used.

Read the Error Responses topic for more info about how errors are returned.

Example

This example grants the users john@contoso.com and ryan@external.com access to a sharing link without modifying other existing permissions on the link.

Request

POST https://graph.microsoft.com/beta/shares/{encoded-sharing-url}/permission/grant
Content-type: application/json

{
  "recipients": [
    {
      "email": "john@contoso.com"
    },
    {
      "email": "ryan@external.com"
    }
  ],
  "roles": ["read"]
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

HTTP/1.1 200 OK
Content-type: application/json

{
  "value": [
    {
      "hasPassword": false,
      "id": "5fab944a-47ec-48d0-a9b5-5178a926d00f",
      "link": {
        "preventsDownload": false,
        "scope": "users",
        "type": "view",
        "webUrl": "https://contoso.sharepoint.com/:t:/g/design/EZexPoDjW4dMtKFUfAl6BK4BvIUuss52hLYzihBfx-PD6Q"
      },
      "roles": [
        "read"
      ]
    }
  ]
}

Note: The response object shown here might be shortened for readability.

If the link is an existing access link, additional permissions will be returned representing the following:

  • User-type permissions representing recipients who were successfully granted access. These can be identified by presence of the grantedTo property.
  • Link-type permissions representing invitations that need to be sent to unrecognized external users for them to gain access. These can be identified by the presence of an invitation facet. These entries will contain a link with the invitation URL, and the grantedToIdentities collection will indicate the users to whom the link should be sent.
HTTP/1.1 200 OK
Content-type: application/json

{
  "value": [
    {
      "hasPassword": false,
      "id": "00000000-0000-0000-0000-000000000000",
      "link": {
        "preventsDownload": false,
        "scope": "existingAccess",
        "type": "view",
        "webUrl": "https://contoso.sharepoint.com/teams/design/shareddocs/Document.docx"
      },
      "roles": [
        "read"
      ]
    },
    {
      "grantedTo": {
        "user": {
          "displayName": "John Smith",
          "email": "john@contoso.com",
          "id": "47aecee2-d061-4730-8ecb-4c61360441ae"
        }
      },
      "id": "aTowIy5mfG1lbWJlcnNoaXB8bGltaXRlZDJAa2xhbW9kYi5vbm1pY3Jvc29mdC5jb20",
      "roles": [
        "read"
      ]
    },
    {
      "grantedToIdentities": [
        {
          "user": {
            "email": "ryan@external.com"
          }
        }
      ],
      "invitation": {
        "signInRequired": true
      },
      "roles": [
        "read"
      ],
      "link": {
        "type": "view",
        "webUrl": "https://contoso.sharepoint.com/:t:/g/teams/design/EZexPoDjW4dMtKFUfAl6BK4Bw_F7gFH63O310A7lDtK0mQ"
      }
    }
  ]
}

Note: The response object shown here might be shortened for readability.