Microsoft Ignite NZ 25-28 October 2016 SKYCITY, Auckland
Building Cross-Platform Mobile Applications with Xamarin and the Microsoft Graph Andrew Coates Microsoft @coatsy http://blogs.msdn.com/acoat
Office Platform WHAT CAN I BUILD? ADD-INS AND WEB PARTS: Microsoft Ignite 2016 11/9/2018 2:08 PM Office Platform WHAT CAN I BUILD? ADD-INS AND WEB PARTS: Make your solution a native part of the modern Office WEB AND DEVICE APPS: Build smarter apps by connecting to Office services VOICE, VIDEO, CONNECTORS, AND BOTS: Create the next generation of productivity solutions © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Agenda Excel REST API and SDK Xamarin Forms Authentication with MSAL Bringing it all together
Excel REST API and SDK
Excel Powered Apps: Workbook as a service TechReady 23 11/9/2018 2:08 PM Excel Powered Apps: Workbook as a service Power your app with 700+ Excel APIs Available over drives API in Microsoft Graph Supports OneDrive Business, Office 365 Groups & SharePoint online files Access secured by OAuth2.0 Uses JSON format for both input and output © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Excel REST API in Microsoft Graph 11/9/2018 2:08 PM Excel REST API in Microsoft Graph Your App Microsoft Graph API (graph.microsoft.com) USERS GROUPS FILES MAIL CALENDAR EXCEL Microsoft Graph rich relationships and insights © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Excel REST API in Microsoft Graph TechReady 23 11/9/2018 2:08 PM Excel REST API in Microsoft Graph Get workbook GET https://graph.microsoft.com/v1.0/me/drive/items/<id>/workbook Microsoft Graph Path to file in OneDrive, SharePoint or Office 365 groups Excel REST API © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Sample queries - reporting Change the background fill color of range A1:A6 PATCH .../workbook/worksheets('Sheet1')/range(address='A1:A6')/format/fill { color: "#FF0000" } Create a column clustered chart with data from A1:C6 POST .../workbook/worksheets('Sheet1')/charts/add { "type": "ColumnClustered", "sourcedata": "A1:C6", "seriesby": "Auto" } Get the chart created as an image GET .../workbook/worksheets('Sheet1')/charts('Chart1') /image(width=0,height=0,fittingMode='fit')
Sample queries – calc and data manipulation Use functions POST .../workbook/functions/pmt { "rate": 0.035, "nper": 20, "pv": -2000 } Sort data in range A1:A6 POST .../workbook/worksheets('Sheet1')/range(address='A1:A6')/sort/apply { fields: [{ key: 0, ascending: true }] } Filter the Table1 to get the top 3 items based on the 1st column POST .../workbook/worksheets('Sheet1')/tables('Table1')/columns/itemAt(index=0)/filter/apply { criteria: { filterOn: "topPercent", criterion1: "3" } }
Microsoft Graph SDKs support Excel REST API GA: .Net/Xamarin and Android Preview: Node.js, JavaScript Coming: iOS, Ruby, PHP // Create a chart based on the table range. var workbookChart = await graphClient.Me.Drive.Items[excelFileId] .Workbook .Worksheets[“Sheet1"] .Charts .Add("ColumnStacked", "Auto", tableRange.Address) .Request() .PostAsync();
Excel REST API Scenarios TechReady 23 11/9/2018 2:08 PM Excel REST API Scenarios Data Management Automate data collection through API and integration with other services. Consuming existing data in Excel. Worksheet Automation Manage worksheet remotely from your app without UI. Automate workflows around worksheets. Calculation Service Leverage the most powerful calculation engine. Reporting Service Get professional charts, powerful data analysis, even PivotTable all with a simple API call. © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Microsoft Graph SDK Target the /v1.0 branch TechReady 23 11/9/2018 2:08 PM Microsoft Graph SDK Target the /v1.0 branch Decoupled for easy authentication integration Active Directory Authentication Library (ADAL) Microsoft Authentication Library (MSAL) … Available on multiple platforms UWP, iOS, Android and ASP.NET MVC More coming soon… Consistent primitives © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Consistent primitives TechReady 23 11/9/2018 2:08 PM Consistent primitives // C# var user = graphServiceClient.Me.Request().GetAsync(); // Do something... // Java graphServiceClient.getMe().buildRequest().get(new ICallback<User>() { // Do something… }); // Obj-C [[[graphServiceClient me] request] getWithCompletion:^(MSGraphUser *user, NSError *error){ }]; © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
TechReady 23 11/9/2018 2:08 PM Codename “Vipr” https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Xamarin Forms
Xamarin Forms
Pages
Layouts
Controls
XAML Markup or Code
Authentication with MSAL
Register your app to use the Microsoft Graph TechReady 23 11/9/2018 2:08 PM Register your app to use the Microsoft Graph Every app must (v1) be registered in an Azure Active Directory tenant declare in advance that it will access the Microsoft Graph declare in advance all of the permission scopes it needs for the Microsoft Graph Every app must (v2) be registered in the Application Registration Portal (https://apps.dev.microsoft.com/) “Spend most of your time building the parts of your app that add value and differentiate it from the crowd.” – Application Registration Portal © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Gotchas You need PCL Profile 7 (no WP8) Default is 111 TechReady 23 11/9/2018 2:08 PM Gotchas You need PCL Profile 7 (no WP8) Default is 111 Edit the Project file © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Gotchas (Android and iOS) You need a custom PageRenderer so MSAL knows how the login dialog will be rendered See https://blog.xamarin.com/authenticate-mobile-apps-using-microsoft-authentication-library/
Gotchas (Android) Turn off Fast Deployment TechReady 23 11/9/2018 2:08 PM Gotchas (Android) Turn off Fast Deployment © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Gotchas (Android cont) TechReady 23 11/9/2018 2:08 PM Gotchas (Android cont) Enable x-machine CPU support in Hyper-V © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Bringing it all together Demo
Resources Excel Developer Centre Excel Developer Session at Ignite US https://dev.office.com/excel Excel Developer Session at Ignite US https://channel9.msdn.com/Events/Ignite/2016/BRK3306 Xamarin.Forms and Graph Session at Ignite US https://channel9.msdn.com/Events/Ignite/2016/BRK3114
Resources Main MS Graph Landing Page MS Graph Change Log TechReady 23 11/9/2018 2:08 PM Resources Main MS Graph Landing Page https://graph.microsoft.io MS Graph Change Log https://graph.microsoft.io/changelog Excel REST API Documentation http://graph.microsoft.io/en-us/docs/api-reference/beta/resources/excel //build MSAL announcement https://blogs.technet.microsoft.com/ad/2016/03/31/microsoft-identity-at-build-2016/ © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resources (cont) Office Developer Show on MSAL TechReady 23 11/9/2018 2:08 PM Resources (cont) Office Developer Show on MSAL https://channel9.msdn.com/Shows/Office-Dev-Show/Office-Dev-Show-Episode-27-Azure-AD-Converged-Authentication-and-the-Microsoft-Graph Office Developer Show on Excel REST API https://channel9.msdn.com/Shows/Office-Dev-Show/Office-Dev-Show-Episode-28-Microsoft-Graph-and-Excel-APIs iOS Simulator on Windows https://developer.xamarin.com/guides/cross-platform/windows/ios-simulator/ © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resources (Sample Code) TechReady 23 11/9/2018 2:08 PM Resources (Sample Code) Xamarin Blog on MSAL and Forms https://blog.xamarin.com/authenticate-mobile-apps-using-microsoft-authentication-library/ https://github.com/OfficeDev/Microsoft-Graph-ASPNET-REST-Excel-Donations https://github.com/microsoftgraph/xamarin-csharp-connect-sample © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resources (//build/ videos) TechReady 23 11/9/2018 2:08 PM Resources (//build/ videos) Microsoft Graph Overview https://channel9.msdn.com/Events/Build/2016/P569 Working with Excel Documents with the Microsoft Graph https://channel9.msdn.com/Events/Build/2016/P556 What's New with Microsoft Graph SDKs https://channel9.msdn.com/Events/Build/2016/P563 What's New in the People API on the Microsoft Graph https://channel9.msdn.com/Events/Build/2016/P571 © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resources (Office Blog Posts) TechReady 23 11/9/2018 2:08 PM Resources (Office Blog Posts) Microsoft Graph findMeetingTimes API update http://dev.office.com/microsoft-graph-findmeetingtimes-api-update Office Dev PnP Web Cast – Introduction to Microsoft Graph for Office 365 developer http://dev.office.com/blogs/Introduction-to-Microsoft-Graph-for-Office-365-developer © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Questions Building Cross-Platform Mobile Applications with Xamarin and the Microsoft Graph M369 Andrew Coates Microsoft @coatsy http://blogs.msdn.com/acoat
Give you app Office365 Super Powers TODAY graph.microsoft.io
11/9/2018 2:08 PM © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.