Aspose.Email 24.6 for .net Exchange impersonation issue

Hello!
Recently, I updated Aspose.Email from 19.10 to 24.6.
After that, I got 'Aspose.Email.ExchangeException: ‘The account does not have permission to impersonate the requested user.’ exception from code:

IEWSClient connection = EWSClient.GetEWSClient(
serverUrl,
new OAuthNetworkCredential(mailboxUsername, AccessToken)

I’m trying to connect to Exchange cloud https://outlook.office.com/ews/exchange.asmx.
I also would like to notice, that this code works fine with 19.10.

What’s wrong? Is there any chance to fix the problem in code?

Regards

Hello @volodymyry ,

Welcome to our support forum!

You need to use the URL “https://outlook.office365.com/EWS/Exchange.asmx”.
Additionally, there is a working example on GitHub that only requires you to insert your credentials.

Best regards.

Hello @dmitry.samodurov ,
Thank you for your answer and provided example.
I’ve trying https://outlook.office365.com/EWS/Exchange.asmx also, but result is the same - same exception.

I’ve analyzed your example and found out, that you are using ConfidentialClientApplicationBuilder, which works with flows, that doesn’t requires login UI. My application built up using Auth code flow, that requires login UI. Therefore, it uses PublicClientApplicationBuilder. May be, there are such types of examples…?

Anyway, what goes wrong? Why do I have this exception after update?

P.S. Also, it would be great to have a squeeze of changes from 19.10 to 24.6 made in frames of EWSClient login functionality… May be, I’ll find the problem out…

@volodymyry ,

Thank you for feedback.

You can find an example using PublicClientApplicationBuilder here.

Regarding your request for a list of changes in EWSClient from version 19.10 to 24.6, unfortunately, we cannot provide a comprehensive list as a significant amount of time has passed since that version. However, if you could share the code you’re using to obtain the access token, we might be able to help identify the issue.

Solved my issue. This ticket can be closed.

Awesome, glad your issue is fixed! If you need any further assistance, feel free to reach out.