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.
This commit is contained in:
Henning Surmeier 2018-06-01 12:39:37 +02:00 committed by Nick Craig-Wood
parent c5286ee157
commit f1269dc06a
1 changed files with 9 additions and 1 deletions

View File

@ -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