Univeral App using O365 API

Preview:

DESCRIPTION

Office 365 API to get the Calendar events and the details

Citation preview

Welcome to Cloud Era

UNIVERSAL WINDOWS APP DEVELOPMENT WITH

OFFICE 365 APIBY SENTHAMIL SELVAN, 15 NOV 2014

SPONSORED BY

TODAY SCHEDULE

AGENDAAbout Me Blog

My Published Apps

Universal App What is Universal App?

User Perspective

Store Perspective

Developer Perspective

Building Universal App

App Template

Shared Projects

Demo

Integrating Office 365

Connected Service

Data Source

Authentication

Office 365 Service Communication

Client Object

Operations

SENTHAMIL SELVAN

• Microsoft MVP (Windows Consumer Apps)

• Working as Solution Architect at Xchanging Pte Ltd

• Blog: http://altfo.wordpress.com

• FB: www.facebook.com/altfo

• My Page: https://www.facebook.com/pages/Math-Formulas-App/546631962132092

• WPUG: https://www.facebook.com/groups/apolloexplorer/

Animal Taxonomy IUPAC Math Formulas Ultimate Player SG Parking SG Things To Do Mani Samayal Ultimate Cryptex SEASPC

UNIVERSAL APP

7

WHAT IS A UNIVERSAL APP?

You can build an app that targets Windows and Windows Phone

It is not (currently):

• A single binary

• A non-Windows binary (Xamarin) application

• Targeting iOS

• Targeting Android

• An HTML/JavaScript (Cordova) application

WHAT DOES IT MEAN TO BE UNIVERSAL?

The consumer promise

• Similar theme

• Common experience

• Shared authentication

• Shared data/profile

• Single app purchase

• Single IAP purchase

WHAT DOES IT MEAN TO BE UNIVERSAL?

The Windows Store perspective

• Shared package full name

• Single app purchase

• Single IAP purchase

• Roaming data

• Shared notification channel

WHAT DOES IT MEAN TO BE UNIVERSAL?

The Visual Studio perspective

• Shared project-type

• A new feature or bug in oneproject, everything is updated

• Still possible to tailor

• Reusing code is meaningful because of unified APIs

BUILDING UNIVERSAL APPS

UNIVERSAL APP PROJECT TEMPLATE

• Solution contains three projects

• Windows

• Phone

• Shared

• Shared is a special project type

• File type is “shproj”

• Does not contain references

• Does not build

UNIVERSAL APP PROJECT TEMPLATE

• Shared items imported into other projects

• Compile-time constants

• #if WINDOWS_APP

• #endif

• #if WINDOWS_PHONE_APP

• #endif

Universal App project template

Demo

16

OFFICE 365 INTEGRATION

ADD OFFICE 365 TO UNIVERSAL APP

Add Connected Service

Need to add to both Windows and Phone projects

Create a data source

XAML makes heavy use of data binding, embrace that paradigm

Stateful client

Initiate login/consent and store Discovery Context

ADDING CONNECTED SERVICES

Project > Add > Connected Service…

Register your app

CONNECTED SERVICES PERMISSIONS

Select required app permissions

ADD CONNECTED SERVICE

Installs NuGet Packages for Office 365 and dependencies

OAUTH IMPLEMENTATION

Web-based apps use passive authentication

Accomplished via browser redirects

Universal Apps use active authentication

App code (or library code) initiates call to authentication source

The “Connected Service” wizard adds the appropriate library

Microsoft.Office365.OAuth.Web.dll for web projects

Microsoft.Office365.OAuth.WindowsStore.dll for native projects

AUTHENTICATION IN O365 API LIBRARIES

How it worksCreate a DiscoveryContext

DiscoveryContext will invoke WebAuthenticationBroker (WAB)

WAB will display logon form and common consent form

if (_discoveryContext == null){

_discoveryContext = await DiscoveryContext.CreateAsync();}

AUTHENTICATION UI

OFFICE 365 SERVICE COMMUNICATION

“Client” objects for each service

ExchangeClient

SharePointClient

Constructor takes a “token getter” function

DiscoveryContext wraps an AuthenticationContext

AuthenticationContext has methods for getting tokens

“CLIENT” OBJECT CONSTRUCTOR EXAMPLE

return new ExchangeClient(ExchangeServiceEndpointUri, async () =>{return (await _discoveryContext.AuthenticationContext

.AcquireTokenSilentAsync(ExchangeServiceResourceId, _discoveryContext.AppIdentity.ClientId, new ActiveDirectory.UserIdentifier(

dcr.UserId,UserIdentifierType.UniqueId)

)).AccessToken;

});

Office 365 Service Communication

Client Object exposes properties

Most are IEnumerable<T> collections

Designed much like Entity Framework

Client == DataContext

IEnumerable<T> entities

Includes common CRUD operations

Office 365 Integration

Demo

Resources

Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 2.12.111071459

Install-Package Microsoft.Office365.OAuth.Windows

http://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment

http://msdn.microsoft.com/en-us/office/office365/howto/authenticate-and-use-services

http://blogs.msdn.com/b/windowsappdev/archive/2012/07/17/roaming-your-app-data.aspx

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

EVALUATE THIS SESSION

There will be other prizes including Bluetooth devices,

Office 365 subscriptions, Xbox Live subscriptions and more!

Assemble at CCF12

Win…

Recommended