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();
authContext.getIdToken('https://outlook.office365.com/')
.then(function(token) {
// Promise callback: Authentication succeeded
client = newExchange.Client(
'https://outlook.office365.com/ews/odata',
token.getAccessTokenFn('https://outlook.office365.com')
);
});
Using the constructed client object, you can then access all messages from the Inbox:
// Use getFolder to access Inbox folder
client.me.folders.getFolder("Inbox").fetch()
.then(function(folder) {
// Retrieve all the messages
folder.messages.getMessages().fetch()
.then(function(mails) {
// mails.currentPage contains all the mails in Inbox
});
});
To get contacts, simply call getContacts:
client.me.contacts.getContacts().fetch()
.then(function(contacts) {
// 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.
Try out the APIs and let us know your feedback. If you run into any issues or have questions, you can connect directly with the product team via UserVoice, Twitter, StackOverflow, or email.