While running some SharePoint Online -PowerShell commandlets, or connecting to a SharePoint Online site from your app, you get a following (or similar) error about your SharePoint Online credentials being unauthorized for something you should definitely be authorized to do:
Cannot contact web site 'https://<tenant>-admin.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'.
And that’s not all – by digging into the full error message, you find the underlying internal error:
What awakens my curiosity, is this line:
Access denied. Before opening files in this location, you must first browse to the web site and select the option to login automatically.
However, when you open your browser, you can actually log in without a hitch. If that’s the case, this might be a weird internal error in SharePoint Online. Nothing you can do permissions/configuration-wise, but luckily – there’s a hazy and weird, but simple PowerShell-based fix!