Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I use a provider hosted Apps, so need to work with an App Web and Lists.

Could anybody provide a code snippet to get ClientContext() of the App?

Can I do something like this?

Uri appWeb = new Uri(HttpContext.Current.Request.QueryString["SPAppWebUrl"]);
using (var clientContext = TokenHelper.GetS2SClientContextWithWindowsIdentity(appWeb, HttpContext.Current.Request.LogonUserIdentity))
{
   ...
}
share|improve this question
3  
Have you seen this blog greggalipeau.com/category/sharepoint-2013/apps/… –  Robert Lindgren Apr 17 '13 at 14:08
    
@RobertLindgren, Thanks a lot! It's a very helpful site for me! –  Warlock Apr 17 '13 at 14:10
    
Seemed to be! Good luck! –  Robert Lindgren Apr 17 '13 at 14:11
1  
@Warlock if you found a solution you should answer your own question. –  Gabriel Smoljár Feb 21 at 12:26

1 Answer 1

You can get the context of host web and app web to use SharePoint lists and libraries from your tenant and app as well. Contexttoken is mostly used in low-trust provider hosted app. In low-trust provider hosted app, you have to use Azure to host your web application. Azure is providing SPAppToken in url, by getting that you can get authentication token for app. SPHostUrl and SPAppWebUrl are also provided in url. You can get that from url and use that urls to get context.

Here you can get some reference about basic SharePoint Provider hosted app.

Some Links for reference

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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