2

Has anyone had any luck authenticating for a EWS SOAP request from PHP using the EWS Callback token instead of a username / password? I have been looking at the PHP-EWS project that comes up when you search for this on google but it only supports username / password authentication as far as I can tell.

Here is an example on how to do what I want to do, but it uses C# not PHP and I can't figure out how to translate what's going on here into something I can use in PHP. http://msdn.microsoft.com/en-us/library/dn148008(v=office.15)

I'm working on an Outlook Mail app that will allow my users to save the current email they are viewing to our database linked to a specific client. I am actually rebuilding an old Outlook Add-in that was originally built using VB.net a few years ago. The new architecture to use for Outlook Add-ins allows you to build apps that run in Outlook on desktop, mobile, and OWA. Unfortunately the new architecture doesn't allow as much direct access to the mail items within the application itself. Instead, you are supposed to use the getCallbackTokenAsync method in the app to get a token that you pass along with a EWS url and Item ID to your web based backend so the backend can make a SOAP request directly to the Exchange server to get properties from a mail item such as attachments.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
OneSimpleGeek
  • 138
  • 11

1 Answers1

2

We don't have a PHP example, but to make a proper request, first construct the body of the request (the SOAP EWS request itself), then set the authorization header to be "bearer" and put the token right after. It should look like this over the wire "Authorization: Bearer abcdef1234...=="

What is the exact problem you are having? Can you share the code you wrote to construct the web request?

Also, we have a dedicated forum for apps for office here: http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=appsforoffice

AndrewS
  • 369
  • 1
  • 5
  • My basic problem is that all the examples I could find that use PHP use the NTLM authentication which I assume I do not want because I'm authenticating with a token, and not a username / password combo. I will give it a shot and comment with my results. – OneSimpleGeek Sep 23 '14 at 00:12
  • 1
    Thanks AndrewS for the tip about the format of the header. I was able to modify the php ews library I found on github to use the callback token for authentication instead of the username / password. If anyone is interested in doing this, you just need to modify NTLMSoapClient.php so the __doRequest method of the NTLMSoapClient class adds an http header of "Authorization: Bearer ".$YourCallbackToken and make sure that you modify that method to not include curl_setopt calls that setup the username / password authentication. – OneSimpleGeek Sep 24 '14 at 14:12
  • Awesome! Glad you got that working. Let us know, if you have any other questions. – AndrewS Sep 24 '14 at 21:25