Red Shirt Tour Paris 2018 - Hands On Lab MS Graph API
- Introduction
- Prerequisites
- Exercice 1 : Register and configure the app
- Exercice 1 : Implement AuthentificationService
- Build and debug
- Questions and comments
- Additional resources
This Repo will help you step by step throw exercices to implement Graph API in a Xamarin Forms application. Connection to Graph API, get all groups, list in a view all events associated, display event informations and Subscribe to one.
This sample requires the following:
- Visual Studio 2015
- Xamarin for Visual Studio
- Windows 10 (development mode enabled)
- Either a Microsoft or Office 365 for business account
If you want to run the iOS project in this sample, you'll need the following:
- The latest iOS SDK
- The latest version of Xcode
- Mac OS X Yosemite(10.10) & above
- Xamarin.iOS
- A Xamarin Mac agent connected to Visual Studio
You can use the Visual Studio Emulator for Android if you want to run the Android project.
-
Into the App Registration Portal using your account provide during the Red Shirt Dev Tour Lab session.
-
Select Add an app.
-
Enter a name for the app, and select Create.
The registration page displays, listing the properties of your app.
-
Under Platforms, select Add platform.
-
Select Native Application.
-
Copy the Application Id value and the Custom Redirect URI value (under the Native Application header) that was created for you when you added the Native Application platform. This URI should contain your Application Id value and be in this form:
msal<Application Id>://auth
You'll need to enter these values into the sample app.The app id is a unique identifier for your app.
-
Select Save.
- Command are already implemented in the MainViewModel
- A exception will occure during the run time because the AuthentificationService is not created.
- We are going to create a singleton GraphServiceClient object in GetAuthenticatedClient()
- GraphServiceClient needs :
- A url (https://graph.microsoft.com/v1.0)
- A DelegateAuthenticationProvider with a TOKEN and a simple AuthorizationHEader
- The token can be retrived by a simple async method that we will create GetTokenForUserAsync()
- GraphLibrary provide a method that generate a WebView AcquireTokenAsync
- We need to managed this call multiple time. Save the token and managed the expirationTime (Let's say 5 mins)
- Implement a sign Out method that erase all object
Step1 | Step2 | Step3 | Step4 |
---|---|---|---|
Copyright (c) 2017 Cellenza. All rights reserved. Lab Red Shirt Dev Tour 23 January 2018