OfficeDev / ews-java-api

A java client library to access Exchange web services. The API works against Office 365 Exchange Online as well as on premises Exchange.
MIT License
867 stars 557 forks source link

The request failed. The remote server returned an error: (440) Login Timeout #777

Closed naeem-epi closed 3 months ago

naeem-epi commented 3 months ago

I've integrated the ExchangeService, but encountered an error when attempting to run it. The error message indicates: "The request failed. The remote server returned an error: (440) Login Timeout."

Below is the code I'm using for your reference. Provide the dummy cred. I've tried both the autodiscovery URL and providing the exact URL, but the result remains the same. Additionally, I've tried using different dependencies, but the outcome persists.

<dependency>
      <groupId>com.microsoft.ews-java-api</groupId>
      <artifactId>ews-java-api</artifactId>
      <version>2.0</version>
</dependency>
<dependency>
      <groupId>com.surevine</groupId>
      <artifactId>ews-java-api</artifactId>
      <version>2.9</version>
</dependency>
import java.net.URI;
import java.text.ParseException;

import microsoft.exchange.webservices.data.core.ExchangeService;
import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName;
import microsoft.exchange.webservices.data.core.service.folder.Folder;
import microsoft.exchange.webservices.data.credential.ExchangeCredentials;
import microsoft.exchange.webservices.data.credential.WebCredentials;

public class EWSService {
    public static void main(String args[]) throws ParseException
    {
    try {
        //String exchangeUrl = "https://example.com/Exchange.asmx";
        String exchangeUrl = "https://autodiscover.example.com/owa";

        String username ="groupid\\Example";                      
            String password = "test"; 
            String emailId="example@outlook.com";

            ExchangeService service = new ExchangeService();
            ExchangeCredentials credentials = new WebCredentials(username, password);
            service.setCredentials(credentials);
            service.setUrl(new URI(exchangeUrl));

           //service.autodiscoverUrl(emailId, new RedirectionUrlCallback());

         // Bind to the Inbox.
            Folder inbox = Folder.bind(service, WellKnownFolderName.Inbox);
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}

I also attempted to verify the connection by running the ping command in CMD with my Exchange URL, and I received successful responses. Furthermore, I tried logging in via a browser and successfully accessed the system. Despite these efforts, the issue persists.

I would greatly appreciate any assistance that anyone can offer.