Forum Discussion
MichaelDenmark
Aug 25, 2022Copper Contributor
EWS with oAuth "An internal server error occurred. The operation failed."
Hi... Since yesterday, my synchronization application starts throwing exceptions with the following error "An internal server error occurred. The operation failed." It only happen for mai...
Mikhail295
Sep 16, 2022Copper Contributor
We have fixed this problem:
1. Get token with scope - `https://outlook.office365.com/EWS.AccessAsUser.All`
2. Add the token to headers:
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setUrl(URI.create("https://outlook.office365.com/ews/exchange.asmx"));
service.getHttpHeaders().put("Authorization", "Bearer " + token);
- Sorin332Jan 02, 2023Copper Contributor
prestonsbutler Mikhail295 MichaelDenmark
We have a working app using Basic Authentication and we migrated to Oauth 2 but we receive this error from EWS.
Uncaught SoapFault exception: [a:ErrorInternalServerError] An internal server error occurred. The operation failed.
Our app was implemented long time ago in PHP using php-ews library, so we updated the library to this one which supports Oauth 2.
We generated the token using their api https://login.microsoftonline.com/{{tenant_id}}/oauth2/token and client_credentials flow since there is no user interaction.We use Office 365 Exchange Online permissions with full_access_as_app and https://outlook.office365.com/.default scope to generate the token. We use X-AnchorMailbox header and impersonate soap header as well.
Do you have any clue how to fix it?