KB #1011: “Unauthorized” when doing backup of SharePoint Online and/or OneDrive
Challenge
Doing backup of SharePoint Online and/or Onedrive results in the following error:
'Error: The request failed with HTTP status 401: Unauthorized.’
Or
‘Error: Cannot contact web site 'https://example.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=1, X-MSDAVEXT_Error=917656; Access+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the+web+site+and+select+the+option+to+login+automatically."'
Solution
Allow legacy protocols. This can by using one of the two solutions:
In SharePoint Online admin center, under "Acces control” - “Apps that don´t use modern authentication”, select “Allow”
Use the following cmdlet in this Microsoft article.
Cause
Legacy protocols are disabled within the tenants Microsoft 365 settings. The SharePointOnlineCredentials class is used by the backup service to authenticate SharePoint Online resources and are denied access.