Table of Contents
This sample uses the Office 365 APIs Preview client libraries to demonstrate basic operations against the Calendar, My Files, and Users and Groups service endpoints in Office 365. It also demonstrates how to authenticate against multiple Office 365 services in a single app experience, and retrieve user information from the Users and Groups service. Below are the operations that you can perform with this sample:
Calendar
- Add events
- Refresh the calendar
- Update events
- Remove events
My Files
- Get files and folders
- Create new files
- Delete files or folders
- Read file contents
- Update file contents
- Download files
- Upload files
Users and Groups
- Get display name
- Get job title
- Get profile picture
- Get user ID
- Check signed in/out state
This sample requires the following:
- Visual Studio 2013 with Update 3.
- Office 365 API Tools version 1.1.728.
- An Office 365 developer site.
- At least one sign-on to OneDrive for Business via the web browser.
###Configure the sample
Follow these steps to configure the sample.
- Open the O365-APIs-Start-Windows.sln file using Visual Studio 2013.
- Register and configure the app to consume Office 365 services (detailed below).
###Register app to consume Office 365 APIs
You can do this via the Office 365 API Tools for Visual Studio (which automates the registration process). Be sure to download and install the Office 365 API tools from the Visual Studio Gallery.
- In the Solution Explorer window, choose Office365Starter project -> Add -> Connected Service.
- A Services Manager dialog box will appear. Choose Office 365 and Register your app.
- On the sign-in dialog box, enter the username and password for your Office 365 tenant. We recommend that you use your Office 365 Developer Site. Often, this user name will follow the pattern @.onmicrosoft.com. If you do not have a developer site, you can get a free Developer Site as part of your MSDN Benefits or sign up for a free trial. Be aware that the user must be an Tenant Admin user—but for tenants created as part of an Office 365 Developer Site, this is likely to be the case already. Also developer accounts are usually limited to one sign-in.
- After you're signed in, you will see a list of all the services. Initially, no permissions will be selected, as the app is not registered to consume any services yet.
- To register for the services used in this sample, choose the following permissions: - (Calendar) – Have full access to users’ calendar - (My Files) – Edit or delete users’ files and Read users’ files - (Users and Groups) – Read and write directory data, Read directory data, and Enable sign-on and read users’ profiles (preview)
- After clicking OK in the Services Manager dialog box, assemblies for connecting to Office 365 REST APIs will be added to your project. Note: After adding the connected service, three sample files are added to the solution: CalendarApiSample.cs and MyFilesApiSample.cs, and ActiveDirectoryApiSample.cs. You may delete these files from the solution as there are no dependencies on these code files in this app.
After you've loaded the solution in Visual Studio, press F5 to build and debug. Run the solution and sign in with your organizational account to Office 365.
Helper Classes
- CalendarOperations.cs
- FileOperations.cs
- UserOperations.cs
- AuthenticationHelper.cs
View Models
- CalendarViewModel.cs
- EventViewModel.cs
- FilesViewModel.cs
- FileSystemItemViewModel.cs
- UserViewModel.cs
You may run into an authentication error after deploying and running if apps do not have the ability to access account information in the Windows Privacy Settings menu. Set Let my apps access my name, picture, and other account info to On. This setting can be reset by a Windows Update.
Known issues as of 9/4
- You need to use the same credentials to login with the app that were used to configure the connected service in Visual Studio.
- You cannot switch users when using the app.
Copyright (c) Microsoft. All rights reserved.