EWS API (Java) OAuth not working

671 Views Asked by At

I am facing an issue with EWS OAuth, my requirement is to access mailbox of other users(EWS permissions are set). I got oauth2 authorization token and trying to do:

    service.getHttpHeaders().put("Authorization", "Bearer <token>");
    service.autodiscoverUrl("<email id>", new RedirectionUrlCallback());

and I get this error: microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException: The Autodiscover service couldn't be located.

Any idea?

1

There are 1 best solutions below

1
On

AFAIK you can't get an oAuth Token that will work against the Autodiscover endpoint in office365 (Autodiscover and EWS are different webservices so EWS permissions won't do). You don't really need to do an autodisccover in Office365 as the endpoint will should be https://outlook.office365.com/EWS/Exchange.asmx.

Cheers Glen