我可以使用__requestdigest在CSOM上下文中进行身份验证吗? [英] Can i autenticate in CSOM context using the __requestdigest?

查看:70
本文介绍了我可以使用__requestdigest在CSOM上下文中进行身份验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个web api来将数据放入SharePoint列表中,并使用javascript在SharePoint页面中使用此api,但所有操作都与web api应用程序池的用户配合使用。我可以将__requestdigest传递给CSOM上下文的autenticate吗?如果没有,我可以怎么做
? 

I developed a web api to put data in SharePoint lists, and consume this api in SharePoint pages using javascript, but all actions are maked with the web api application pool's user. Can i pass the __requestdigest to autenticate on CSOM context? If not, how can i do it? 

推荐答案

我们可以使用SharePointContextProvider来传递身份验证。以下文章供您参考。

We can use SharePointContextProvider to pass the authentication. The following article for your reference.

http://blog.baslijten.com/getting-sharepoint-2013-apps-and-webapi-to-work/

在SharePoint 2013中,我们可以使用带有jQuery的SharePoint REST API直接将列表项添加到SharePoint页面中的SharePoint列表。以下代码供您参考。

In SharePoint 2013, we can use the SharePoint REST API with jQuery directly to add list items to SharePoint lists in SharePoint Pages. The following code for your reference.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
var listName="CustomList";  
function AddListItem(){
	var itemType = GetItemTypeForListName(listName);
    var item = {
        "__metadata": { "type": itemType },
        "Title":


(&#;# AddListItemTxt")。val()
};
("#AddListItemTxt").val() };


.ajax({
url:_spPageContextInfo.siteAbsoluteUrl +" / _ api / web / lists / getbytitle(' " + listName +"')/ items",
type:" POST",
contentType:" application / json; odata = verbose",
data:JSON.stringify (item),
标题:{
" Accept":" application / json; odata = verbose",
" X-RequestDigest":
.ajax({ url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items", type: "POST", contentType: "application/json;odata=verbose", data: JSON.stringify(item), headers: { "Accept": "application/json;odata=verbose", "X-RequestDigest":


这篇关于我可以使用__requestdigest在CSOM上下文中进行身份验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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