Rest 对Microsoft Sharepoint API的curl请求?

Rest 对Microsoft Sharepoint API的curl请求?,rest,sharepoint,curl,sharepoint-2013,sharepoint-api,Rest,Sharepoint,Curl,Sharepoint 2013,Sharepoint Api,有没有一种简单的方法可以使用对RESTAPI的请求来访问我的Sharepoint帐户上的文件?比如说 curl -i -H "Authorization: Bearer <some-key-here>" https://mysharepoint.com/_api/web/Lists curl-i-H“授权:承载”https://mysharepoint.com/_api/web/Lists 我已经阅读了有关的所有文档,但在本例中,我没有可以注册的“应用程序”。我只需要在REST请

有没有一种简单的方法可以使用对RESTAPI的请求来访问我的Sharepoint帐户上的文件?比如说

curl -i -H "Authorization: Bearer <some-key-here>" https://mysharepoint.com/_api/web/Lists
curl-i-H“授权:承载”https://mysharepoint.com/_api/web/Lists
我已经阅读了有关的所有文档,但在本例中,我没有可以注册的“应用程序”。我只需要在REST请求中使用某种API密钥。如何以这种方式使用RESTAPI


我非常感谢您对这个问题的深入了解。

如果这仍然是相关的,那么这就为我做到了:

curlhttps://mysharepoint.com/_api/web/Lists -v--ntlm--协商-u用户:密码

您基本上使用ntlm进行身份验证(注意,某些共享点可能需要Kerberos),然后可以像通过浏览器一样轻松访问RESTAPI


“编辑”显然不适用于Office 365。

创建bash脚本:

$ nano get_access_token.sh
将下一个内容粘贴到其中,将
YourTenant
client\u id
client\u secret
更改为您自己的值(您可以在下面的Sharepoint部分获得)

应用适当的权限:
chmod 700 get\u access\u token.sh

您可以使用
curl
作为下一种方式的标记:

curl-i-H“Authorization:Bearer$(./get\u access\u token.sh)”-H“Accept:application/json;odata=verbose“-s”https://YourTenant.sharepoint.com/_api/web“

您可以用脚本的完整路径替换
/

Sharepoint部分:
  • 通过注册新应用程序
    • 以下
      https://YourTenant.sharepoint.com/_layouts/15/appregnew.aspx
      链接
    • 生成客户端Id和**客户端机密**值
    • 填充标题应用程序域重定向URI字段(我已经输入了图片上的localhost.com,它可以正常工作)
    • 单击创建按钮
  • 将下一个参数保存到文件中的某个位置:

    The app identifier has been successfully created.
    Client Id:      898c898f-89238-43d0-4b2d-7a64c26f386a
    Client Secret:  4/T+21I1DSoAJdOX9DL1Ne4KssEaP7rqb11gdtskhXn=
    Title:          SomeTitle
    App Domain:     localhost.com
    Redirect URI:   https://localhost.com/default.aspx
    
  • 通过将权限应用于此应用

    • 以下
      https://YourTennant.sharepoint.com/sites/SharePointRND/_layouts/15/appinv.aspx
    • 客户端Id
      898c898f-89238-43d0-4b2d-7a64c26f386a
      插入应用程序Id字段
    • 单击查找按钮
    • 粘贴到权限请求XML下一个代码中(在我的情况下,我只需要
      读取
      访问权限,因此我将
      s值从
      完全控制
      更改为
      读取
      ):

    • 信任它点击按钮

  • 但这对Office 365租户不起作用,是吗?我想应该这样。不幸的是,我现在无法测试它,您可以确认它不工作或工作吗?我可以确认它不工作,至少对我来说:
    访问被拒绝。您没有执行此操作或访问此资源的权限。
    The app identifier has been successfully created.
    Client Id:      898c898f-89238-43d0-4b2d-7a64c26f386a
    Client Secret:  4/T+21I1DSoAJdOX9DL1Ne4KssEaP7rqb11gdtskhXn=
    Title:          SomeTitle
    App Domain:     localhost.com
    Redirect URI:   https://localhost.com/default.aspx
    
    <AppPermissionRequests AllowAppOnlyPolicy="true">
    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />