Step 4 – Registering App in SharePoint & Providing Permission
In this article, we will learn to register SharePoint Add-In. Do not get confused by word SharePoint Add-In. App and Add-In points to same object.
We will be using SharePoint UI Interface to register and then providing access to App.
Register SharePoint Add-In
New Apps can be register from “AppRegNew.aspx” page.
Open the below URL
http://<<site collection URL>>/_layouts/15/appregnew.aspx
In AppRegNew page below details are needed –
- Client ID – It can be any GUID. Click on “Generate” button to auto populate this field.
- Client Secret – This is secret for App. You can give your own value OR Click on “Generate” button to auto populate
- Title – Provide any name for App. In my case “TokenConnectionApp”
- AppDomain – www.localhost.com
- Redirect URL – https://www.localhost.com
Once all details are filled, click next to complete the registration process. But before clicking Next, note down each value as they are needed later for multiple purposes. Once the app registration is completed, SharePoint show you all details last time to Save.
Now we registered the App but as you see we didn’t provide any permission to Add-In. So still our App is unable to access SharePoint data. Next we will give access to this newly registered App.
Provide Permission to SharePoint Add-in
Access to SharePoint App can be done from “AppInv.aspx” page.
Open below URL –
http://<web URL>>/_layouts/15/appinv.aspx
In AppInv.aspx page, We need to search for Client ID for which permission/details needs to be updated. As we have Client ID with us created earlier, put this client ID to Search. It will populate all details for Add-In. Down below there is a section for App Permission.
Before adding value in Permission XML, Few things we need to know –
- Scope for App can be –
- Site Collection
- Web
- List
- Permission level / Rights can be –
- Read
- Manage
- Full Control
Here I am providing few example for permission.xml. You can use any below or based on your requirement Scope and Rights can be updated.
- Ex1 – Read Access on Site Collection
<AppPermissionRequests> <AppPermissionRequest Scope="htp://sharepoint/content/sitecollection" Rights="Read" / > </AppPermissionRequests>
- Ex2 – Full Control Access on Web
<AppPermissionRequests> <AppPermissionRequest Scope="htp://sharepoint/content/sitecollection/web" Rights="FullControl" / > </AppPermissionRequests>
- Ex3 – Read Access on List
<AppPermissionRequests> <AppPermissionRequest Scope="htp://sharepoint/content/sitecollectionweb/list" Rights="Read" / > </AppPermissionRequests>
Once you provide, permission XML as your requirement, Click Update. In next page SharePoint asks you to trust the app with the permission you provided. Click “Trust” to continue.
Note – If you have scope as List then you need to select the List on which App access is needed.
Conclusion
In this article, we learned to register and providing permission to SharePoint Add-in. Now we can use this add-in in WCF to connect to SharePoint.
Checkout next post to on this topic “How to access SharePoint from WCF”
12,916 total views, 4 views today
2 Comments
CurrentBody France · January 8, 2022 at 12:01 PM
Great content! Keep up the good work!
Best AGV & AMR Materials · January 24, 2022 at 1:19 PM
Very impressive and detailed article shared. Interesting and informative post thanks for share with us.