Forum Discussion

arunsankr8955's avatar
arunsankr8955
Copper Contributor
Jun 25, 2020

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

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;
        }
    }

Resources