univeral app using o365 api
DESCRIPTION
Office 365 API to get the Calendar events and the detailsTRANSCRIPT
![Page 1: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/1.jpg)
Welcome to Cloud Era
![Page 2: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/2.jpg)
UNIVERSAL WINDOWS APP DEVELOPMENT WITH
OFFICE 365 APIBY SENTHAMIL SELVAN, 15 NOV 2014
![Page 3: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/3.jpg)
SPONSORED BY
![Page 4: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/4.jpg)
TODAY SCHEDULE
![Page 5: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/5.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/6.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/7.jpg)
UNIVERSAL APP
7
![Page 8: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/8.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/9.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/10.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/11.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/12.jpg)
BUILDING UNIVERSAL APPS
![Page 13: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/13.jpg)
![Page 14: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/14.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/15.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/16.jpg)
Universal App project template
Demo
16
![Page 17: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/17.jpg)
OFFICE 365 INTEGRATION
![Page 18: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/18.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/19.jpg)
ADDING CONNECTED SERVICES
Project > Add > Connected Service…
Register your app
![Page 20: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/20.jpg)
CONNECTED SERVICES PERMISSIONS
Select required app permissions
![Page 21: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/21.jpg)
ADD CONNECTED SERVICE
Installs NuGet Packages for Office 365 and dependencies
![Page 22: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/22.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/23.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/24.jpg)
AUTHENTICATION UI
![Page 25: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/25.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/26.jpg)
“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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/27.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/28.jpg)
Office 365 Integration
Demo
![Page 29: Univeral App using O365 API](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/29.jpg)
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](https://reader031.vdocuments.net/reader031/viewer/2022020105/559a586e1a28ab204a8b464c/html5/thumbnails/30.jpg)
EVALUATE THIS SESSION
There will be other prizes including Bluetooth devices,
Office 365 subscriptions, Xbox Live subscriptions and more!
Assemble at CCF12
Win…