There is way given by the Microsoft for connecting to Exchange Online PowerShell using the Client ID and client secret using Preview version described in https://docs.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2?view=exchange-ps
enter image description here
But this one is giving a problem with Password length.
Here is the PowerShell script I am using: $AuthenticationResult = Invoke-RestMethod -Uri https://login.microsoftonline.com/{tenant_Name}/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://outlook.office.com/"; "client_id" = "ClientID"; "client_secret" =" CLientSecret "}
$PlainPassword = “bearer ” +$AuthenticationResult.access_token
$SecurePassword = $PlainPassword | ConvertTo-SecureString -AsPlainText -Force
$UserName="userName"
$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $UserName, $SecurePassword
Connect-ExchangeOnline -Credential $Credentials
enter image description here
Can anyone help me with this?
Thanks in Advance.