Office 365 Client APIs for Hybrid Mobile Apps
The Visual Studio Tools for Apache Cordova enable developers to build mobile apps for iOS, Android, and Windows using web standards technologies. When used with the Office 365 API Tools for Visual Studio, developers can access Office 365 APIs from their hybrid mobile applications to access to the user’s calendar, contacts, mail, and files from their Office 365 account to easily create a richer, more connected experience.
Both the Tools for Apache Cordova and the Office 365 API Tools are extensions for Visual Studio 2013. Building a hybrid mobile app that queries data from a REST service can be hard: you’ll need to manage authentication tokens, construct REST URIs dynamically, and handle errors and retries. This code is boilerplate but is often error prone, the Office 365 APIs handle this complexity for you so you can focus on building your app. In addition to handling the complexity of REST calls, the library also provides APIs for authentication and discovery, OneDrive My Files usage, and accessing user and group information.
For example, a hybrid mobile app could easily add calendar appointments directly into a user’s Exchange calendar, send mail on behalf of the user, or directly access their files stored in OneDrive. With few lines of code, users can authenticate and access their Office 365 account.
Below, you can see how to authenticate a user and create a client object that serves as the base for accessing all the APIs from Exchange. The getIdToken method prompts for a username and password to authenticate against outlook.office365.com.
var authContext = newO365Auth.Context();
// Promise callback: Authentication succeeded
client = newExchange.Client(
Using the constructed client object, you can then access all messages from the Inbox:
// Use getFolder to access Inbox folder
// Retrieve all the messages
// mails.currentPage contains all the mails in Inbox
To get contacts, simply call getContacts:
// contacts.currentPage contains the contacts information
Similarly, use the getEvents method to retrieve calendar events. Here are few screenshots of our Woodgrove Demo app that uses Office 365 APIs to authenticate, fetch user’s calendar appointments and displays them in the app.
To get started building a hybrid mobile app using Office 365 APIs in Visual Studio 2013, install the Tools for Apache Cordova Preview and the Office 365 API Tools for Visual Studio 2013. You can find a walkthrough on adding the Office 365 service to your app on MSDN. You can also follow a tutorial on using the SharePoint APIs to access OneDrive files.
|Suresh Jayabalan, Senior Program Manager, Visual Studio Client Platform Tools Team
Suresh Jayabalan is a Program Manager on the Visual Studio team, focusing on mobile app development technologies and Apache Cordova.