From 6ad8a4dfa7f87b7ed885f2208f49335ba28c8c9a Mon Sep 17 00:00:00 2001 From: Christian Baune Date: Thu, 10 Aug 2023 19:32:41 +0200 Subject: [PATCH] Update permission-grant.md Copied the explanation of the encoding from: shares-get.md And also added the path parameter description. --- api-reference/v1.0/api/permission-grant.md | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/api-reference/v1.0/api/permission-grant.md b/api-reference/v1.0/api/permission-grant.md index 53a0ed424dc..64af16adaf8 100644 --- a/api-reference/v1.0/api/permission-grant.md +++ b/api-reference/v1.0/api/permission-grant.md @@ -30,6 +30,29 @@ One of the following permissions is required to call this API. To learn more, in POST /shares/{encoded-sharing-url}/permission/grant ``` +### Path parameters + +| Parameter Name | Value | Description | +|:-------------------------------|:---------|:------------------------------------------------------------------------------------| +| **encoded-sharing-url** | `string` | Required. A properly encoded sharing URL. | + +### Encoding sharing URLs + +To encode a sharing URL, use the following logic: + +1. First, use base64 encode the URL. +2. Convert the base64 encoded result to [unpadded base64url format](https://en.wikipedia.org/wiki/Base64) by removing `=` characters + from the end of the value, replacing `/` with `_` and `+` with `-`.) +3. Append `u!` to be beginning of the string. + +As an example, to encode a URL in C#: + +```csharp +string sharingUrl = "https://onedrive.live.com/redir?resid=1231244193912!12&authKey=1201919!12921!1"; +string base64Value = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(sharingUrl)); +string encodedUrl = "u!" + base64Value.TrimEnd('=').Replace('/','_').Replace('+','-'); +``` + ## Request headers | Name | Description |