Enable modern authentication office 365

First time:
Install-Module ExchangeOnlineManagement

Commands:
Connect-ExchangeOnline

Set-OrganizationConfig -OAuth2ClientProfileEnabled $true

Check:
Get-OrganizationConfig | Format-Table Name,OAuth* -Auto