From f1269dc06a863854a073b999a7083e6fa4a13eec Mon Sep 17 00:00:00 2001 From: Henning Surmeier Date: Fri, 1 Jun 2018 12:39:37 +0200 Subject: [PATCH] onedrive: errorHandler for business requests This implementation hopefully can handle all error requests from the onedrive for business authentication. I have only tested it with the "domain in unmanaged state" error. --- backend/onedrive/onedrive.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 09399d603..e9e34e165 100644 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -97,7 +97,15 @@ func init() { log.Fatalf("Failed to configure token: %v", err) } } else { - err := oauthutil.Config("onedrive", name, oauthBusinessConfig, oauthBusinessResource) + err := oauthutil.ConfigErrorCheck("onedrive", name, func(req *http.Request) oauthutil.AuthError { + var resp oauthutil.AuthError + + resp.Name = req.URL.Query().Get("error") + resp.Code = strings.Split(req.URL.Query().Get("error_description"), ":")[0] // error_description begins with XXXXXXXXXXXX: + resp.Description = strings.Join(strings.Split(req.URL.Query().Get("error_description"), ":")[1:], ":") + resp.HelpURL = "https://rclone.org/onedrive/#troubleshooting" + return resp + }, oauthBusinessConfig, oauthBusinessResource) if err != nil { log.Fatalf("Failed to configure token: %v", err) return