提供者托管的应用程序-如何获取当前用户的rtfa cookie [英] Provider hosted app - how to get rtfa cookie of the current user

查看:138
本文介绍了提供者托管的应用程序-如何获取当前用户的rtfa cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用提供商托管的应用程序.我想获取列表项的版本集合,为此,它只是尝试使用list.asmx服务进行访问.要调用此SP服务,必须传递cookie(FedAuth和rtFa).但是我只有accesstoken,有什么办法可以获取当前已登录用户的cookie?

我尝试过的事情:

我试图使用带有访问令牌的HttpWebRequest调用list.asmx服务,它抛出401异常.它要求cookie或凭据. (用户已经在浏览器中登录SharePoint网站,因此我无法要求用户为此提供凭据).因此,最好使用cookie.

I am using Provider-Hosted App. I want to get version collection of list item, for that just tried to access using list.asmx service. To call this SP service, have to pass cookie(FedAuth and rtFa). but i have only accesstoken with me, is any way to get cookie of the current logged in user?

What I have tried:

I have tried to call list.asmx service using HttpWebRequest with access token, it throws 401 exception. it ask for either cookie or credentials. (user already logged in the SharePoint site in browser, so i could not ask user to give credentials for this). so my better option to go with cookie.

推荐答案

嗨 为了清楚起见,借助可用的远程API,您能否仅调用API而不使用webrequests?

像下面的
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

使用(var clientContext = spContext.CreateUserClientContextForSPAppWeb())
{
Web Web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();

ListCollection列表= web.Lists;
clientContext.Load< listcollection>(列表);
clientContext.ExecuteQuery();
}
Hi Just for clarity, with remote API s available , Can''t u just call the API instead of using webrequests?

like below
var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

using (var clientContext = spContext.CreateUserClientContextForSPAppWeb())
{
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();

ListCollection lists = web.Lists;
clientContext.Load<listcollection>(lists);
clientContext.ExecuteQuery();
}


这篇关于提供者托管的应用程序-如何获取当前用户的rtfa cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆