Error connecting to SharePoint Online with PowerShell

Posted by

While I was doing some PowerShell scripting for a client, I received a weird error in SharePoint Online, the console it was throwing errors like “Unauthorized” and “…the web site does not support SharePoint Online credentials” even though my username and password is fine.

I tried with Connect-PnPOnline and other legacy commands, with the same bad result, but what is happenning backwards?

SharePoint Online has a setting named “LegacyAuthProtocolsEnabled” with the purpose “Prevents Office clients using non-modern authentication protocols from accessing SharePoint Online resources .”.

By default this is allowed in all tenants. But as an administrator it is possible to tighten up the security and disallow us to login with these non-modern approaches.

More details can be found here: https://technet.microsoft.com/en-in/library/fp161390.aspx

Solution

1. Start using modern authentication (recommended)

Check if your application support the use of modern authentication through either WebLogin or using application credentials (ClientId/ClientSecret) authentication. This is advice to be the recommended and a more secure approach.

2. Re-enable support for legacy apps

connect-sposervice “https://tenant-admin.sharepoint.com”
set-spotenant -legacyauthprotocolsenabled $True

Updating SharePoint Online tenant settings does not take immediate effect. So is it possible that you will need to wait a while, exact how long can be from from minutes to 24 hours with the different settings.

Till next time!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s