Lets see how to create and deploy a Provider Hosted App on Office 365
In this series of posts, I will be posting my experience following along to the Microsoft Virtual Academy course on SharePoint Online Development for Office 365. Follow along to create and deploy a provider hosted app on your Office 365 tenant.
- Open Visual Studio and create a new project by going to Office/SharePoint and App for SharePoint 2013.
- Select Provider-hosted and enter your Office 365 developer site url and click next.
- Lets select ASP.NET MVC Web Application.
- Leave the default Use Windows Azure Access Control Service option and click finish.
- Now, we can go ahead and deploy the app by clicking on the Start button
Since we are connecting from local machine to Office 365, visual studio will create a self-signed Localhost certificate and the app will be hosted locally on https://localhost for debugging. Click Yes on the following prompt to trust the certificate.
- Click Yes on the Thumbprint prompt.
- Deploy the app by clicking on Start button.
- Click on ‘Trust It’ when it asks for permssions to access basic information.
- The home page of the MVC application is displayed with your name displayed in the welcome page
If you have a look at the HomeController.cs, we can see that client side object model is used to display the logged in user.
This can be customized to add our custom logic and the MVC application can be customized. We are currently viewing the remote web created by the app. The app will have full permission on the remote web.
However, if we want to access the host web or the host SharePoint Site, we need to explicitly request for the permissions in the AppManifest.xml. Double clicking on the AppManifest.xml will show the following dialog.
Here we can select the scope of the permissions and the required permission such as Read, Write etc.
After we select a scope such as List and deploy the app, when a user tries to install the app, it will ask to select a list from all lists to grant permission to the app. If we want to request the permission for a specific list, we can specify that in the Properties text area.
For example, if we say BaseTemplateId=101, it will only show the document libraries to the user to select from. From the above dialog, we can click on the edit button on the properties to enter the properties through the UI.
Even though we can use the UI to update the properties, we can look at the xml view and update the properties in the xml also. See the MSDN link App permissions in SharePoint 2013 for more information on App permissions.