2

We need to setup provider hosted app in dedicated server and consume in Office 365. Is it possible?

If yes, then how we can take "ClientContext" to read/write operation to Office 365 Web list?

2 Answers 2

3

Yes , It can be done by following the steps we used to do with High Trusted Apps Deployment(Server to Server) in On Premises ,

Self signed certificate for your web app in local IIS
Register app using appregnew.aspx
Use the client secret and ID in the web.config

Please refer this for detailed info on this topic: https://bishwadebdey.blogspot.com/2016/01/step-by-step-creation-of-provider.html?showComment=1486621176030#c1394076155011092551

3
  • Hi... When I am deploying my app to Office 365 with Office 365 AppRegNew and respective web.config I am not able to take ClientContext object. In above link they are not using ClientContext. I am able to open site but I need to do operation further. Commented Feb 9, 2017 at 10:02
  • 1
    we can get the clientcontext like this: var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request); var hostWeb = Page.Request[“SPHostUrl”]; using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority)) { clientContext.Load(clientContext.Web, web => web.Title, user => user.CurrentUser); clientContext.ExecuteQuery(); }
    – Esaki
    Commented Feb 9, 2017 at 12:30
  • While using above code ClientContex not getting "OAuth2AccessTokenResponse" from TokelHelper class file which is provider by Microsoft. Can you elaborate this reason? Commented Feb 10, 2017 at 4:52
4

Yes it is possible. I worked on a provider hosted add-in which I deployed in IIS and was used by O365. When you create the add-in, give O365 site URL and log in. After that select SP Online as earliest version of SP that you want your app to target. Next you can select Web Forms or MVC according to your wish and use Windows Azure Access Control Service (for SP cloud apps)

Now you can deploy the app wherever you want. Give URL of IIS website while publishing and make the domain public.

I am not going into detailed steps as you will find many links on internet like this

Regarding, ClientContext use it in the same way as you will find in demo code which comes after the project is created. No difference.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.