From 63a24255f88e958be14ee6ef7adae9e6141ad532 Mon Sep 17 00:00:00 2001 From: Alex Chen Date: Tue, 27 Jul 2021 17:55:57 +0800 Subject: [PATCH] onedrive: handle HTTP 400 better in PublicLink() (#5419) --- backend/onedrive/onedrive.go | 4 +++- docs/content/onedrive.md | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 349a201b6..556629d91 100755 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -1500,7 +1500,9 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, return shouldRetry(ctx, resp, err) }) if err != nil { - fmt.Println(err) + if resp != nil && resp.StatusCode == 400 && f.driveType != driveTypePersonal { + return "", errors.Errorf("%v (is making public links permitted by the org admin?)", err) + } return "", err } diff --git a/docs/content/onedrive.md b/docs/content/onedrive.md index 19660441c..8e03bf9da 100644 --- a/docs/content/onedrive.md +++ b/docs/content/onedrive.md @@ -582,3 +582,12 @@ Description: Due to a configuration change made by your administrator, or becaus ``` If you see the error above after enabling multi-factor authentication for your account, you can fix it by refreshing your OAuth refresh token. To do that, run `rclone config`, and choose to edit your OneDrive backend. Then, you don't need to actually make any changes until you reach this question: `Already have a token - refresh?`. For this question, answer `y` and go through the process to refresh your token, just like the first time the backend is configured. After this, rclone should work again for this backend. + +#### Invalid request when making public links #### + +On Sharepoint and OneDrive for Business, `rclone link` may return an "Invalid +request" error. A possible cause is that the organisation admin didn't allow +public links to be made for the organisation/sharepoint library. To fix the +permissions as an admin, take a look at the docs: +[1](https://docs.microsoft.com/en-us/sharepoint/turn-external-sharing-on-or-off), +[2](https://support.microsoft.com/en-us/office/set-up-and-manage-access-requests-94b26e0b-2822-49d4-929a-8455698654b3).