Cannot contact web site or the web site does not support sharepoint online credentials

In this SharePoint Online tutorial, we will discuss, how to fix the error, cannot contact web site or the web site does not support sharepoint online credentials.

The web site does not support sharepoint online credentials

Recently while working with CSOM in SharePoint Online by using the SharePointPnPCoreOnline.dll, I got the error, Cannot contact web site ‘https://tsinfotechnologies.sharepoint.com/’ or the web site does not support SharePoint Online credentials. The response status code is ‘Unauthorized’. The response headers are ‘X-SharePointHealthScore=0, X-MSDAVEXT_Error=917656; Access.

The error looks like below:

the web site does not support sharepoint online credentials
the web site does not support sharepoint online credentials

I just wrote a simple CSOM code to get the website title like below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OfficeDevPnP.Core.Entities;
using Microsoft.SharePoint.Client;
using System.Configuration;
namespace conrosdemo
{
    class Program
    {
        static void Main(string[] args)
        {
            OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
            
            string PWD = ConfigurationManager.AppSettings["PWD"];
            string siteURL = "https://tsinfotechnologies.sharepoint.com/sites/enjoysharepoint";
            string userName = "[email protected]";          
            using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, PWD))
            {
                ctx.Load(ctx.Web);
                ctx.ExecuteQuery();
                string s= ctx.Web.Title;
            }
        }
    }
}

The above error was coming on the below line:

ctx.ExecuteQuery();

Here, the username and password were correct, still, the error “the web site does not support sharepoint online credentials” was coming.

The same error can also come in PowerShell.

c# the web site does not support sharepoint online credentials – Fix

To fix the error, cannot contact web site or the web site does not support sharepoint online credentials, follow the below steps:

  • Open SharePoint Online admin center (https://tsinfotechnologies-admin.sharepoint.com/)
  • This click on Policies -> Access control. Here we need to verify two options on Unmanaged devices and Apps that don’t use modern authentication.
cannot contact web site or the web site does not support sharepoint online credentials
cannot contact web site or the web site does not support sharepoint online credentials
  • First, click on Unmanaged devices and Here make sure, Allow full access from desktop apps, mobile apps and the web option is selected like below:
c# the web site does not support sharepoint online credentials
  • Then click on Apps that don’t use modern authentication and make sure, Allow access option is selected there.
The response status code is Unauthorized sharepoint online
The response status code is Unauthorized sharepoint online

After enabling the above two options, when you run the C# CSOM code, the error will not appear. It will execute successfully.

PowerShell

We can also use Microsoft PowerShell to enable or disable the above options.

Open SharePoint Online management shell, then run the below commands.

Connect-SPOService
Set-SPOTenant -LegacyAuthProtocolsEnabled $True
Set-SPOTenant -RequireAcceptingAccountMatchInvitedAccount $False

Note: It may take up to 30 minutes to reflect the changes.

Check out the below posts:

This is how to fix the error, cannot contact web site or the web site does not support sharepoint online credentials.

>