none
[EWS Managed Api][office 365 exchange online] How to use EWS managed Api in office 365 exchange online? RRS feed

  • Question

  • Hi there, I have been looking for a way to use EWS managed Api 2.0 with office 365 exchange online via Azure AD. There must be a way to use EWS managed api with office 365 exchange online. Ews managed Api is the only thing which supports full permission with Exchange  Mailbox, I want to take advantage of this beautiful Api.

    Or  is there any other way to  access office 365 exchange online without Azure AD ? I am using Azure AD to authenticate against office 365 exchange online and using office 365 Rest api which is not working properly and not supporting full access. 

    best regards,

    Friday, November 21, 2014 11:35 AM

Answers

  • Hi SharpDragon,

    I am glad you are unblocked!  You can use EWS Managed API with OAuth:

    service.Credentials = new OAuthCredentials(tokenx);

    If this doesn't work for you, please provide us all headers returned with the request and response you received, especially x-ms-diagnostics  returned by server.  This will help us investigate the failure.

    The app must have “full access to users’ mailbox” right to work against EWS.  Re: your question #1, multiple customers have migrated from GMail to Office 365.  So, unless there are specific items that have issues with migration, you should be ok. 

    Re: your question #2, the EWS Managed API does include support for tasks.  See here for more details.  The Managed API uses SOAP APIs over the wire and not Office 365 REST APIs. Adding support for tasks in Office 365 REST APIs is in our roadmap, but the timeframe is yet to be decided.

    Let me know if you have any questions or need more info.

    Thanks,
    Venkat


    Tuesday, December 2, 2014 4:46 AM

All replies

  • Hi SharpDragon,

    What is the issue you are running into with Office 365 REST APIs?  While we don't support full access, we do support multiple permissions that should give you access to the data you need.  Do you mind explaining your scenario?  Maybe we can unblock you with using the REST APIs.

    Thanks,

    Venkat

    Friday, November 21, 2014 4:36 PM
  • Yes sir, Let me try to explain me about my scenario. I need to use EWS managed Api with office 365 Rest Api to get benefits from both the Apis. Here is here code I am using to connect to EWS managed Api but it is failing with 401:Unauthorized.  I already have "Full Access" turned on in Azure AD.  I have the access token from AZure AD and want to use it to make call against EWS managed Api.

    var outlookClient = await AuthHelper.EnsureOutlookServicesClientCreatedAsync("Mail"); //IPagedCollection<IMessage> messagesResults = await outlookClient.Me.Messages.ExecuteAsync(); // Get the ID of the first message. // string messageId = messagesResults.CurrentPage[0].Id; string tokenx = AuthHelper.GetAccessToken(); ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013); service.HttpHeaders.Add("Authorization", "Bearer " + tokenx); service.PreAuthenticate = true; service.SendClientLatencies = true; service.EnableScpLookup = false; service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"); // Get all the folders in the message's root folder. ExFolder rootfolder = ExFolder.Bind(service, WellKnownFolderName.MsgFolderRoot);S

    Scenario of my migration application:

    1. I have a Gmail mailbox email in Raw(complete email in base64-urlsafe with attachments) format with RFC2822. I need to migrate this mailbox to Exchange online. I believe EWS managed Api has better support on this one.

    2.  Likewise I need to migrate Gmail Calendars, Tasks and Contacts to Exchange online.

    I would be highly grateful to you , if you tell me how to bridge EWS managed Api with office 365 Api.

    best regards,

     

    Saturday, November 22, 2014 5:12 AM
  • Hi SharpDragon,

    Thanks for the detailed info!  I will look into this for you but it may take some time as my team is out for the week due to Thanksgiving holiday in US.  In the meantime, are you able to just use Basic over HTTPS authentication (email address and password) to unblock yourself?

    Please let me know if you have any questions or need more info.

    Regards,

    Venkat

    Monday, November 24, 2014 1:44 PM
  • thank for taking an interest to help me. :) I have solved the issue of EWS managed Api using oauth2.0 via Azure AD.  I noticed that I can't use EWS managed Api with office365 Api to perform a task as EWS works with full mailbox permission while office365 api doesn't support full mailbox access permission.  Actually this is not my problem anymore as my company's owner said I can use username and password to access office365 Apis.

    My main concern about two things :

    1.  I have to migrate gmail mailbox to office365 exchange online. I wonder if office365 is capable of taking gmail mailbox as it is.. I mean without any formatting issue. Gmail mailbox supports base64-url safe encoded messages with RFC2822 standard. Does office365 support the same formatting ?

    2. Although I am not required to migrate Google Tasks to exchange online but maybe in future our client may ask us to migrate Google Tasks as well.  Office365 Api doesn't support Task right now.

    best regards,

    Monday, November 24, 2014 4:53 PM
  • Hi SharpDragon,

    I am glad you are unblocked!  You can use EWS Managed API with OAuth:

    service.Credentials = new OAuthCredentials(tokenx);

    If this doesn't work for you, please provide us all headers returned with the request and response you received, especially x-ms-diagnostics  returned by server.  This will help us investigate the failure.

    The app must have “full access to users’ mailbox” right to work against EWS.  Re: your question #1, multiple customers have migrated from GMail to Office 365.  So, unless there are specific items that have issues with migration, you should be ok. 

    Re: your question #2, the EWS Managed API does include support for tasks.  See here for more details.  The Managed API uses SOAP APIs over the wire and not Office 365 REST APIs. Adding support for tasks in Office 365 REST APIs is in our roadmap, but the timeframe is yet to be decided.

    Let me know if you have any questions or need more info.

    Thanks,
    Venkat


    Tuesday, December 2, 2014 4:46 AM
  • thanks Venkat. You cleared my doubts. :) Just one more question ?  Can I use office365 Api with simple username and password as I don't want to subscribe to Azure AD , it is adding an extra cost to my company.

    Yes, I am able to authenticate using OAuth2 whether it's EWS managed Api or office365 Api but my companies requirement has changed they want to authenticate using username and password. 

    best regards,

     
    Tuesday, December 2, 2014 2:20 PM
  • Hi SharpDragon,

    You can use EWS Managed API with just username and password since you are using Full access anyway.  For the Office 365 REST APIs, you should use OAuth.  If your company already has an Office 365 tenant, the Azure AD subscription should be free.  Does your company have an Office 365 tenant?

    Thanks,
    Venkat

    Wednesday, December 3, 2014 2:06 PM
  • no, Venktat, we are using the free trial right now for testing purposes.  thanks for good info. :)
    Wednesday, December 3, 2014 4:10 PM