I'm working with the EWS Java API 1.2 in an Android application. Logging in with username/password WebCredentials
is working fine using something like this:
ExchangeService service = new ExchangeService(); ExchangeCredentials credentials = new WebCredentials("domain\\username", "password"); service.setCredentials(credentials);
Instead of supplying the password every time, I'd like to supply an authentication token. The EWS API contains a TokenCredentials
class, but how do I use it? Given a username and password, how do I generate a reusable authentication token? Once I generate such a token, how long is it valid?
Basic authentication is no longer supported for EWS to connect to Exchange Online. Use OAuth authentication in all your new or existing EWS applications to connect to Exchange Online. OAuth authentication for EWS is only available in Exchange Online as part of Microsoft 365.
To use OAuth with your application you will need to: Register your application with Azure Active Directory. Add code to get an authentication token to get an authentication token from a token server. Add an authentication token to EWS requests that you send.
Exchange Web Services (EWS) is an application program interface (API) that allows programmers to access Microsoft Exchange items such as calendars, contacts and email.
You can now use OAuth tokens: http://msdn.microsoft.com/en-us/library/office/dn626019(v=exchg.150).aspx. This topic was just updated a few weeks ago with some basic info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With