Issues connecting to Microsoft Exchange online using PowerShell - app only authentication

3.6k Views Asked by At

I could not connect to Exchange Online, I get the below error while connecting

Error Acquiring Token: System.Exception: In the case of a Federated user(that is owned by a federated IdP, as opposed to a managed user owned in an Azure AD tenant) ID3242: The security token could not be authenticated or authorized.The user does not exist or has entered the wrong pas swordInnerException : Federated service

PowerShell Code

$AppCredential= New-Object System.Management.Automation.PSCredential(<UPN>,<Token>)

Connect-ExchangeOnline -Credential $AppCredential

Reference

https://o365reports.com/2020/07/04/modern-auth-and-unattended-scripts-in-exchange-online-powershell-v2/

1

There are 1 best solutions below

1
On

Connect to Exchange Online using App-only authentication Feature is not available in EXO V2.

Delegation is not possible with app-only authentication. The Secure App Model allows for unattended scripting in delegation scenarios.

Delegation is not supported in this Feature.

Note: Decrease your EXO V2 into V1 then you can use the same scripts to connect the Exchange Online using APP-only Authentication.. But This way is not recommended.

Refer here