【问题标题】:Use sharepoint cross-domain javascript library to consume REST API from localhost使用 sharepoint 跨域 javascript 库从 localhost 使用 REST API
【发布时间】:2016-07-02 07:20:35
【问题描述】:

我尝试使用本地主机中部署的应用程序中的共享点休息 API。 Sharepoint 网站托管在 Sharepoint 2013 在线版中。

为此,我使用 javascrpt 跨域库。我在这里有一个例子https://github.com/OfficeDev/SharePoint-Add-in-REST-OData-CrossDomain

我的应用程序是一个全静态网站,我没有VS,所以我试图弄清楚Add In 授权。我去我网站的_layouts/15/appinv.aspx页面授权第三方应用:

  • 应用域名:localhost:8080
  • 重定向网址:http://localhost:8080(毫无意义?)
  • 权限请求 XML:<AppPrincipal><RemoteWebApplication ClientId="*" /></AppPrincipal>

当我转到我的应用程序时,我已使用我的帐户进行身份验证:cookie 填充有 FedAuthrtFa 中的令牌

我认为现在使用 API 应该足够了:

var executor = new SP.RequestExecutor(addinweburl);

executor.executeAsync(
    {
        url:
            addinweburl + "/_api/web/GetFolderByServerRelativeUrl('Shared%20Documents')"
        ,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function(e) {
            alert('success');
        },
        error: function(e, c, d) {
            alert('fail');
        }
    }
);

调用错误处理程序并发送 1007 错误代码。这很奇怪,因为当大小太重要时会使用此代码。

感谢任何帮助。

【问题讨论】:

    标签: web-services rest sharepoint sharepoint-2013


    【解决方案1】:

    如果应用程序未部署在同一个共享点站点域上,则无法使用该库...

    我回退到 OAuth 协议以验证我的客户端。 以下文档是了解如何获取访问令牌的关键:https://github.com/wearearchitect/sharepoint-oauth-app-client/blob/master/docs/Credentials.md

    【讨论】:

    • 您好,我正在尝试通过独立于 SharePoint 的 Web 应用程序实现类似的功能。我设法加载了 SP.RequestExecutor.js。基本上我需要从部署在不同域中的第三方 Web 应用程序创建一个 SP 站点,而这根本不是 SharePoint。请问可以指导吗?感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    相关资源
    最近更新 更多