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

%3CLINGO-SUB%20id%3D%22lingo-sub-1488175%22%20slang%3D%22en-US%22%3EHow%20to%20use%20Modern%20Authentication%20instead%20of%20Basic%20authentication%20in%20Android%20application%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488175%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22votecell%20post-layout--left%22%3E%3CDIV%20class%3D%22js-voting-container%20grid%20fd-column%20ai-stretch%20gs4%20fc-black-200%22%3E%3CDIV%20class%3D%22js-vote-count%20grid--cell%20fc-black-500%20fs-title%20grid%20fd-column%20ai-center%22%3E%3CSPAN%3EI%20have%20been%20using%20the%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Falipov%2Fews-android-api%22%20target%3D%22_self%22%20rel%3D%22noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EEWS-android-API%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ein%20my%20android%20application%20to%20get%20the%20calendar%20events%20etc..%20According%20to%20the%20docs%2C%20the%20basic%20authentication%20will%20be%20deprecated%20in%20the%20coming%20October%202020.%20I%20believe%20the%20basic%20authentication%20have%20been%20using%20in%20my%20android%20application%2C%20So%20how%20can%20I%20use%20modern%20authentication%20instead%20of%20basic%20authentication%20in%20my%20application%20to%20continue%20using%20the%20EWS-android-API%20in%20my%20projects%20even%20after%20October.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%20class%3D%22postcell%20post-layout--right%22%3E%3CDIV%20class%3D%22post-text%22%3E%3CP%3ELooking%20forward%20to%20your%20suggestions%20and%20support.%3C%2FP%3E%3CP%3EThe%20sample%20code%20used%20for%20login%20in%20my%20android%20application%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22kwd%22%3Eprivate%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Evoid%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20loginEws%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%7B%3C%2FSPAN%3E%0A%20%0A%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EExchangeUser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20user%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EExchangeUser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EmUsername%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20mPassword%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20mExchangeServerUrl%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20mMailboxEmail%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EExchangeHelper%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20helper%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EExchangeHelper%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Euser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20helper%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Elogin%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%0A%20%20%3CSPAN%20class%3D%22kwd%22%3Epublic%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Evoid%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20login%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Ethrows%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EException%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EExchangeService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20service%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20createService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EMailbox%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20mailbox%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EMailbox%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Euser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EgetMailbox%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E())%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EFolderId%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20folderId%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EFolderId%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EWellKnownFolderName%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3ECalendar%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20mailbox%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3ECalendarFolder%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20folder%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3ECalendarFolder%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ebind%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Eservice%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20folderId%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%0A%0A%0A%20%3CSPAN%20class%3D%22kwd%22%3Eprivate%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EExchangeService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20createService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Etry%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EExchangeService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20service%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EExchangeService%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EExchangeVersion%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EExchange2010_SP2%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22typ%22%3EExchangeCredentials%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20credentials%20%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22typ%22%3EWebCredentials%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Euser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EgetUsername%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%2C%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20user%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EgetPassword%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E())%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20%20%20%20%20service%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EsetUrl%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22kwd%22%3Enew%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20URI%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Euser%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EgetServerUrl%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()))%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20%20%20%20%20service%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EsetCredentials%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3Ecredentials%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Ereturn%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20service%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Ecatch%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EURISyntaxException%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20e%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20%20%20%20%20e%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EprintStackTrace%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Ereturn%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enull%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Ecatch%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22typ%22%3EException%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20e%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E)%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pun%22%3E%7B%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3E%20%20%20%20%20%20%20%20%20%20%20%20e%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E.%3C%2FSPAN%3E%3CSPAN%20class%3D%22pln%22%3EprintStackTrace%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E()%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22kwd%22%3Ereturn%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kwd%22%3Enull%3C%2FSPAN%3E%3CSPAN%20class%3D%22pun%22%3E%3B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22pun%22%3E%7D%3C%2FSPAN%3E%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1488175%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Visitor
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
Highlighted

@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-...