Getting Started with Office365 Development – session recording, slides and demo resources

Tags: Office 365, Visual Studio, APIs, Speaking, Conferences, TechEd Europe, Office 365 Saturday, Channel 9, Vimeo

In October and November 2014 I presented session „Getting Started with Office365 Development“ on two conferences: TechEd Europe 2014 and Office365 Saturday Europe 2014. Both sessions are recorded, and recordings are available online: - [TechEd Europe session](http://channel9.msdn.com/Events/TechEd/Europe/2014/DEV-B208) - [Office 365 Saturday session](http://vimeo.com/112154040) **Slides** for TechEd session are [available on Channel9](http://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fsessions%2fteched%2feu%2f2014%2fDEV-B208.pptx) and slides for Office 365 Saturday session can be downloaded [from my SlideShare profile](http://www.slideshare.net/panjkov/getting-started-with-office-365-development-41610225). As I'm currently using Markdown for editing my blog posts, I'm currently not able to embed the presentation directly in a blog post. ## Session demos ## During the session, I had total of 4 coding demos: 1. How to create Office App with Visual Studio 2. How to create SharePoint App with Visual Studio 3. Using Windows Store App to access Files and Calendar data stored on Office 365 4. Using ASP.NET MVC website to access Files and Contacts data stored on Office 365 For **first two demos**, source code of completed apps and code snippets for all steps can be [downloaded from OneDrive](http://1drv.ms/1tapDta). **Third demo** is based on Windows Store App Starter Project [available on GitHub Office Dev](https://github.com/OfficeDev/Office-365-APIs-Starter-Project-for-Windows) repository. **Last demo** is based on [ITUnity tutorial written by Scot Hillier](http://www.itunity.com/article/programming-office-365-apis-general-availability-release-678), but extended to cover "Files" capability scenario. As I had problems preparing this demo, I had huge help from [Andrew Byrne (Microsoft)](https://twitter.com/AndrewJByrne), who helped me to solve the issue which I had with Access Denied, caused by unsuccessful token acquisition for `SharePointClient` object, literally at 2AM in the morning. The trick was to use `UserAssertion` object in `AcquireTokenAsync` call. Below is the code for MVC Controller that reads Files from OneDrive for Business in Office 365 for current user: public class FilesController : Controller { private const string CLIENT_ID = "[Your Client ID]"; private const string CLIENT_SECRET = "[Your Client Secret]"; private const string AUTHORITY = "https://login.windows.net/[Insert Tenant GUID Here]"; const string DISCOVERY_ENDPOINT = "https://api.office.com/discovery/v1.0/me/"; const string DISCOVERY_RESOURCE = "https://api.office.com/discovery/"; const string FILES_CAPABILITY = "MyFiles"; // GET: Files [Authorize] public async Task Index() { var signInUserId = ClaimsPrincipal.Current.FindFirst( ClaimTypes.NameIdentifier).Value; var userObjectId = ClaimsPrincipal.Current.FindFirst( "http://schemas.microsoft.com/identity/claims/objectidentifier").Value; AuthenticationContext authContext = new AuthenticationContext( AUTHORITY, new NaiveSessionCache(signInUserId)); string refreshToken = string.Empty; string accessToken = string.Empty; //Discover contacts endpoint DiscoveryClient discClient = new DiscoveryClient(new Uri(DISCOVERY_ENDPOINT), async () => { var authResult = await authContext.AcquireTokenSilentAsync(DISCOVERY_RESOURCE, new ClientCredential(CLIENT_ID, CLIENT_SECRET), new UserIdentifier(userObjectId, UserIdentifierType.UniqueId)); refreshToken = authResult.RefreshToken; accessToken = authResult.AccessToken; return authResult.AccessToken; }); var dcr = await discClient.DiscoverCapabilityAsync(FILES_CAPABILITY); SharePointClient client = new SharePointClient( dcr.ServiceEndpointUri, async () => { var authResult = await authContext.AcquireTokenAsync(dcr.ServiceResourceId, new ClientCredential(CLIENT_ID, CLIENT_SECRET), new UserAssertion(signInUserId)); return authResult.AccessToken; }); var filesResult = await client.Files.Take(10).ExecuteAsync(); //Show the files return View(filesResult); } } Feel free to download sample code, or use this code block above in your apps. Any questions or comments you can post here, or reach me on twitter: [https://twitter.com/panjkov/](https://twitter.com/panjkov/). Thanks for reading :)

No Comments

Add a Comment