Problem
You might have received the below error when you try to connect SPO site using Connect-SPOService cmdlet.
Connect-SPOService : Could not authenticate to SharePoint Online https://TenantName.sharepoint.com/sites/SiteName
using OAuth 2.0
At line:1 char:1
+ Connect-SPOService -Url https://TenantName.sharepoint.com/sites/SiteName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-SPOService], AuthenticationException
+ FullyQualifiedErrorId : Microsoft.Online.SharePoint.PowerShell.AuthenticationException,Microsoft.Online.SharePoi
nt.PowerShell.ConnectSPOService
Fix/Soution
In my case, I have provided my site URL as opposed to my SharePoint Admin Site URL. The URL parameter of Connect-SPOService cmdlet accepts only the URL of SharePoint Online Administration Center site. My problem solved after providing Admin site URL.
Connect-SPOService -url https://TenantName-admin.sharepoint.com
If you face the problem even with Admin site URL, then pass the -Credential parameter to bypass ADAL/Modern authentication and use legacy authentication.
$PSCred = Get-Credential Connect-SPOService -url https://TenantName-admin.sharepoint.com -Credential $PSCred
Note: The legacy authentication will not work MFA enabled user account.
If you still face the issue, try to re-install the SPO Powershell module, reboot machine and check the case again.
Advertisement
Thaaaaaank you !!!