EWS autodiscoverUrl office365 Could not find Autodiscover service

I am using adal4j to authorize on Azure with an x509 certificate to access all mailboxes of the same Office365 tenant. I managed to get the auth token from adal4j and use it for auth.

TokenCredentials tokenCredentials = new TokenCredentials(authRes.getAccessToken());

                @SuppressWarnings("resource")
                ExchangeService service = new ExchangeService();
                service.setTraceEnabled(true);
                service.autodiscoverUrl("jamie@archiva360.com", new IAutodiscoverRedirectionUrl() {
                    @Override
                    public boolean autodiscoverRedirectionUrlValidationCallback(String arg0)
                            throws AutodiscoverLocalException {
                        // TODO Auto-generated method stub
                        return true;
                    }
                });
                service.setCredentials(tokenCredentials);

      

The problem here is that I am getting the exception:

microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException: The Autodiscover service couldn't be located.
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.internalGetLegacyUserSettings(AutodiscoverService.java:743)
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.getLegacyUserSettings(AutodiscoverService.java:520)
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.internalGetLegacyUserSettings(AutodiscoverService.java:960)
at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.getUserSettings(AutodiscoverService.java:1846)
at microsoft.exchange.webservices.data.core.ExchangeService.getAutodiscoverUrl(ExchangeService.java:3611)
at microsoft.exchange.webservices.data.core.ExchangeService.autodiscoverUrl(ExchangeService.java:3570)
at com.stimulus.archiva.connect.exchange.OAuth2.main(OAuth2.java:66)

      

I am added to hosts autodiscover.outlook.com archiva360.com

But that doesn't help. Any clue how can I authorize with token and access Office365 with EWS for java.

Regards, Valentin

+3


source to share





All Articles