Search code examples
javaoauthms-officeexchangewebservices

EWS java apis using Oauth2


I want to use Oauth2 authentication for my app. I want to use EWS Java apis to fetch data from O365. Is it possible? Document http://blogs.msdn.com/b/exchangedev/archive/2014/09/24/10510847.aspx talks about fetching oauth token for REST apis should I use same document to fetch token to be used with EWS web services also? Can anyone share any code sample doing this with java.


Solution

  • It is possible. You have to register your app in the same way as you do for REST, but you need to specify the special EWS permission "Have full access via EWS to users' mailboxes". You'll need to do the OAuth flow to retrieve the access token, then include that in the Authorization header in your EWS requests. I don't have a Java sample for you, but those are the basic steps required.