How to use Modern Authentication instead of Basic authentication in Android application

Copper Contributor
I have been using the EWS-android-API in my android application to get the calendar events etc.. According to the docs, the basic authentication will be deprecated in the coming October 2020. I believe the basic authentication have been using in my android application, So how can I use modern authentication instead of basic authentication in my application to continue using the EWS-android-API in my projects even after October.

Looking forward to your suggestions and support.

The sample code used for login in my android application

 

private void loginEws(){
 
       ExchangeUser user = new ExchangeUser(mUsername, mPassword, mExchangeServerUrl, mMailboxEmail);
       ExchangeHelper helper = new ExchangeHelper(user);       helper.login();
                 
   }
  public void login() throws Exception {
        ExchangeService service = createService();
        Mailbox mailbox = new Mailbox(user.getMailbox());
        FolderId folderId = new FolderId(WellKnownFolderName.Calendar, mailbox);
        CalendarFolder folder = CalendarFolder.bind(service, folderId);
    }


 private ExchangeService createService() {
        try {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
            ExchangeCredentials credentials = new WebCredentials(user.getUsername(), user.getPassword());            service.setUrl(new URI(user.getServerUrl()));            service.setCredentials(credentials);
            return service;
        } catch (URISyntaxException e) {            e.printStackTrace();
            return null;
        } catch (Exception e) {            e.printStackTrace();
            return null;
        }
    }
1 Reply

@arunsankr8955 Hello, this isn't within my "comfort zone" but I believe you should be looking at OAuth and Microsoft Graph (with the disclaimer that OAuth authentication for EWS is only available in Exchange as part of Office 365). I am attaching these links to guide you in the right direction. Perhaps another member know more about it!

 

https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate...

 

https://techcommunity.microsoft.com/t5/exchange-team-blog/upcoming-changes-to-exchange-web-services-...