univeral app using o365 api

30
Welcome to Cloud Era

Upload: senthamil-selvan

Post on 06-Jul-2015

146 views

Category:

Technology


4 download

DESCRIPTION

Office 365 API to get the Calendar events and the details

TRANSCRIPT

Page 1: Univeral App using O365 API

Welcome to Cloud Era

Page 2: Univeral App using O365 API

UNIVERSAL WINDOWS APP DEVELOPMENT WITH

OFFICE 365 APIBY SENTHAMIL SELVAN, 15 NOV 2014

Page 3: Univeral App using O365 API

SPONSORED BY

Page 4: Univeral App using O365 API

TODAY SCHEDULE

Page 5: Univeral App using O365 API

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

Page 6: Univeral App using O365 API

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

Page 7: Univeral App using O365 API

UNIVERSAL APP

7

Page 8: Univeral App using O365 API

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

Page 9: Univeral App using O365 API

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

Page 10: Univeral App using O365 API

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

Page 11: Univeral App using O365 API

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

Page 12: Univeral App using O365 API

BUILDING UNIVERSAL APPS

Page 13: Univeral App using O365 API
Page 14: Univeral App using O365 API

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

Page 15: Univeral App using O365 API

UNIVERSAL APP PROJECT TEMPLATE

• Shared items imported into other projects

• Compile-time constants

• #if WINDOWS_APP

• #endif

• #if WINDOWS_PHONE_APP

• #endif

Page 16: Univeral App using O365 API

Universal App project template

Demo

16

Page 17: Univeral App using O365 API

OFFICE 365 INTEGRATION

Page 18: Univeral App using O365 API

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

Page 19: Univeral App using O365 API

ADDING CONNECTED SERVICES

Project > Add > Connected Service…

Register your app

Page 20: Univeral App using O365 API

CONNECTED SERVICES PERMISSIONS

Select required app permissions

Page 21: Univeral App using O365 API

ADD CONNECTED SERVICE

Installs NuGet Packages for Office 365 and dependencies

Page 22: Univeral App using O365 API

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

Page 23: Univeral App using O365 API

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();}

Page 24: Univeral App using O365 API

AUTHENTICATION UI

Page 25: Univeral App using O365 API

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

Page 26: Univeral App using O365 API

“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;

});

Page 27: Univeral App using O365 API

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

Page 28: Univeral App using O365 API

Office 365 Integration

Demo

Page 29: Univeral App using O365 API

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/

Page 30: Univeral App using O365 API

EVALUATE THIS SESSION

There will be other prizes including Bluetooth devices,

Office 365 subscriptions, Xbox Live subscriptions and more!

Assemble at CCF12

Win…