This code is a part of post about how to make connection from Sharepoint Online to Azure Web Service authenticated with Azure Active Directory. Please read it in order to get the context of this code.
To test this code you need to have:- Access to Sharepoint Online
However any kind of server that can host HTML+JS code will work Please remember that to properly reproduce behaviour described in mentioned blog post it should be on different domain than web service. - Azure subscription
Required for hosting web service. It should also have active directory for providing desired authentication config.
- Web Service
it's simple ASP.NET WEB API that you deploy on Azure - Sharepoint App (Add-On)
Sharepoint App that you can deploy on SPO in order to test client <-> web service communication. If you want you can just install app as a sandbox solution (I write about it in this post in section: "Create Sharepoint Add-in"). Alternatively you can also just take files from solution and upload it manually (remember to change reference paths inside files).
- In ClientPart/Scripts/ClientPart.js file:
- In CORS section: provide you web service name (part of it's url)
- In Auth section: provide tenant name and clientId in windows.config object
- In WebService/Controllers/ValuesController file:
- In CORS attribute: provide name of your SP tenant
- In WebService/Controllers/ProvisionController file:
- Provide url to your ClientPart.aspx file (just for return redirection purposes)