Login using OAUTH Returns "The request failed with HTTP status 401: Unauthorized."

AuthenticationResult result = context.acquireTokenByRefreshToken(refreshToken, clientCred, null).get();

EWSClient.getEWSClient(urlEWS, new OAuthNetworkCredential(admin, result.getAccessToken()));

so it's return 401 error

Hi Ruzal,


Thank you for posting your inquiry.

The implementation of Logging to Exchange Server using OAuth is specific to Office 365 Exchange Server 2013. By now, Office365 has been moved to Exchange Server 2016 which Aspose.Email API doesn’t support. Could you please share your server information with us for our reference?

Thank you for help.

Server version is 15.1.888.26 . So I think it’s 2016 version

Hi,


Yes that seems to be Exchange 2016 version. As mentioned earlier, the API doesn’t support working with Exchange Server 2016. We have plans for providing support for the same. You can subscribe to the release section of Aspose.Email Release Notes to remain updated about the features of the API.