This sample lists all the Office 365 capabilities available for the signed in Office 365 user such as Mail, Calendar, Contacts, My Files. It will discover the service endpoint Uri and resource Id for each capability which are required later for you to authenticate and get access tokens to those resources.
Note that, in order for your Windows Store application to authenticate to Office 365 discovery service, your Azure AD application should have permissions to at least one Office 365 API service.
Update 12/15/2014 Sample now caches the information from the discovery service so the app doesn't need to query the discovery service everytime to create the respective service client. Since this is a Windows Store app, we use the local storage and write the information in a file called DiscoveryInfo.txt.
You can look at the following class files to understand how the caching works:
To run this sample, you need:
- Visual Studio 2013
- Office 365 API Tools for Visual Studio 2013
- Office 365 Developer Subscription
From your Git Shell or command line:
git clone https://github.com/OfficeDev/Office365-Discovery-Service-Sample.git
- Open the project in Visual Studio 2013.
- Simply Build the project to restore NuGet packages.
Office 365 applications use Azure Active Directory (Azure AD) to authenticate and authorize users and applications respectively. All users, application registrations, permissions are stored in Azure AD.
Using the Office 365 API Tool for Visual Studio you can configure your Windows Store app to consume Office 365 APIs.
- In the Solution Explorer window, right click your project -> Add -> Connected Service.
- A Services Manager dialog box will appear. Choose Office 365 -> Office 365 API and click Register your app.
- On the sign-in dialog box, enter the username and password for your Office 365 tenant.
- 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.
- Select Mail and then click Permissions
- In the Mail Permissions dialog, select Read users' mail profiles' and click Apply
- Select Contacts and then click Permissions
- In the Contacts Permissions dialog, select Read users' contacts and click Apply
- Click Ok
After clicking OK in the Services Manager dialog box, Office 365 client libraries (in the form of NuGet packages) for connecting to Office 365 APIs will be added to your project.
In this process, Office 365 API tool registered an Azure AD Application in the Office 365 tenant that you signed in the wizard and added the Azure AD application details to web.config.
Now you are ready for a test run. Hit F5 to test the app.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.