Italian knowhow on wab on a windows phone; using the exchange API. Or nearly, anyways.


This is excellent (and our code is at https://onedrive.live.com/redir?resid=5061D4609325B60!7427&authkey=!AJRzEViikCFZG5c&ithint=file%2c.zip)

image

http://www.cloudidentity.com/blog/2014/04/16/calling-office365-api-from-a-windows-phone-8-1-app/

Now for a few notes follow of how we necessarily deviated from the suggestions:

image

We used the empty project, as shown above, to get started Then we added bits of code, resolving as required. One has to nuget the JSON.NET package.

image

Don’t understand very much about “activations” – but  I did remove the async keyword from the material given. It makes sense that resources are conserved between screens, though!

Using the windows azure directory portal site, applications tab, we made a native client app (preview) thus:

image

image

 

There are a missing few lines of code in the writeup, shown in the video frame:

image

http://channel9.msdn.com/Events/Build/2014/3-598

private async void ShowMessage(string str) { await (new MessageDialog(str)).ShowAsync(); }

Running it gives

image

image

Hmm. This doesn’t happen when the very same config is used in a windows store app! And, it didn’t happen when we used the Azure Mobile Services client API (for AAD) on a phone.

Anyways, we have learned a few things about the limits. Lets replicate success using exactly the parameters used by the author (to be fair, since Im English – which is code for “remember I’m duping you with such nonsense,so I can spy on you having lowered your guard”)

Lets assume that we restrict ourselves to using the *.onmicrosoft.com IDP (so its pages conform to the limits imposed by the authentication broker). And, let’s ensure that an outlook service account is provisioned, active and has a few memos – so the odata service has something to return:

image

using login as follows

image

We do get something coherent, once we simplify the filter a little:

image

So  a little Italian magic, rather simpler than this official code, does just fine. The 5 year Italian engineering degrees really do seem to be quite special. Its clearly a lot easier than what we had to do with the previous incarnation of getting a list of messages from an Exchange mailbox using soap (discussed https://yorkporc.wordpress.com/2013/07/21/using-the-microsoft-online-issued-token-using-our-own-stss-token-to-authenticate-in-exchange-online/)


For fun, we took the knowhow from that project and used it to replace the (evil) Google demo in the more official sample code. (remember Google policy on aiding and abetting systemic spying on Germans by the US is what is evil, not Google engineers whose contribution is great!)

image

giving for the windows 8.1 app “store” and the the “phone” version of the testing apps:

imageimage

On the windows phone version, we do get to

image

to accomplish this, note our changes from Google to the code from our Italian guru (see below), don’t forget to add #define WINDOWS_PHONE_APP on the first line (so its easier to set breakpoints), and resize textboxes in the (not) google xaml designer to suite the phone screen.

#if WINDOWS_PHONE_APP private void Launch_Click(object sender, RoutedEventArgs e) #else private async void Launch_Click(object sender, RoutedEventArgs e) #endif { string Authority = "https://login.windows.net/rapmlsqa.com"; string Resource = "https://outlook.office365.com/"; string authURL = string.Format( "{0}/oauth2/authorize?response_type=code&resource={1}&client_id={2}&redirect_uri={3}", Authority, Resource, Uri.EscapeDataString(RAPMLSQAClientID.Text), Uri.EscapeDataString(RAPMLSQACallbackUrl.Text)); if (RAPMLSQAClientID.Text == "") { rootPage.NotifyUser("Please enter an Client ID.", NotifyType.StatusMessage); } else if (RAPMLSQACallbackUrl.Text == "") { rootPage.NotifyUser("Please enter an Callback URL.", NotifyType.StatusMessage); } try { String RAPMLSQAURL = authURL; System.Uri StartUri = new Uri(RAPMLSQAURL); // When using the desktop flow, the success code is displayed in the html title of this end uri System.Uri EndUri = new Uri(RAPMLSQACallbackUrl.Text); DebugPrint("Navigating to: " + RAPMLSQAURL); #if WINDOWS_PHONE_APP WebAuthenticationBroker.AuthenticateAndContinue(StartUri, EndUri, null, WebAuthenticationOptions.None); #else WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync( WebAuthenticationOptions.UseTitle, StartUri, EndUri

 

On the store version, we see

 

image

and

image

 

ok. that was useful – seeing how the double project builds works (for “universal apps”), how the libraries vary slightly between the two platforms, and seeing how AAD differs from Google.

Using our own IDP, with the PC store we get

image

image

image

 

and on the phone we see:

image

image

 

 

code is at https://onedrive.live.com/redir?resid=5061D4609325B60!7427&authkey=!AJRzEViikCFZG5c&ithint=file%2c.zip

Advertisements

About home_pw@msn.com

Computer Programmer who often does network administration with focus on security servers. Very strong in Microsoft Azure cloud!
This entry was posted in oauth, odata. Bookmark the permalink.