This sample demonstrates how to upload files to SharePoint Online using Office 365 Authentication and AAD bearer tokens in a multi-tenant application.
To run this sample, you need:
- Visual Studio 2015
- Office Developer Tools For Visual Studio 2015 Update 1
- Office 365 Developer Subscription
From your Git Shell or command line:
git clone https://github.com/dougperkes/O365-SharePoint-FilePush.git
- Open the project in Visual Studio 2015.
- Simply Build the project to restore NuGet packages.
- Ignore any build errors for now as we will configure the project in the next steps.
Once downloaded, open the sample in Visual Studio.
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 web application to consume Office 365 APIs.
- In the Solution Explorer window, right click your project -> Add -> Connected Service.
- The Add Connected Service wizard dialog box will appear. Choose Microsoft -> Office 365 APIs and click Configure.
- On the Select Domain page, enter your Azure AD developer tenant name, i.e. contosodev.onmicrosoft.com.
- Click Next and you will be promted to enter your O365 developer subscription credentials if they have not already been cached by Visual Studio.
- On the Configure Application page, select "Create a new Azure AD application to access Office 365 API services". Click Next
- Click the Sites page and select Run search queries and Read and write items in all site collections
- Click the Users and Groups page and select Sign you in and read your profile
- Click Finish
After clicking Finish in the Add Connected Service 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.