当前位置:网站首页>SharePoint接入简要笔记
SharePoint接入简要笔记
2022-07-17 09:04:00 【CoffeeAndIce】
文章目录
一、前言
整体
SharePoint接入主体主要围绕文件的内容问题,最终目的是将SharePoint涉及的文件内容整合打包迁移,所以这里主要关注的内容为文件相关的内容部分,其他有涉及的会列出相关讯息。
二、概念划分
1、网站/新闻
SharePoint这里展示上通常分类为这两个内容。①新闻服务于网站,也就是依托于网站。
②新闻的素材可以直接从文档库提取。
③文档库可以涵盖你所知道的绝大数内容。
2、公共目录
为组织默认的一个文档目录, 一个商业级的Acount ,都会为其分配一个公共网站目录。
通常我们获取的相对地址的时候,都是基于
Shared Documents目录即可
3、关注目录/文件
主要是已经授予读取权限的网站,我们便可以获取拥有查看权限的文件内容。
①通常为关注整个网站
②可以关注文件/目录
4、签入/签出
其实相当于我们线程阻塞一样,也可以说锁。
签出: 将文档单独拎出,避免其他人操作,你获取了单独修改的权限。
签入: 放回原位,重新释放线程锁。
三、API 操作(sharePoint v1)
相关接口地址参考:
①通用端点地址: https://docs.microsoft.com/zh-cn/sharepoint/dev/sp-add-ins/get-to-know-the-sharepoint-rest-service?tabs=csom
②社交方面端点地址: https://docs.microsoft.com/zh-cn/sharepoint/dev/general-development/following-people-and-content-rest-api-reference-for-sharepoint#bk_GetFollowersFor
1、前置准备
为了测试数据接口可行性,建议:
①预备一个可行性business Acount。
②公共主页上创建至少一个文件夹,且文件夹内任意放一个文件。
③创建一个新网站,同样创建文件夹及文件。
2、获取登录token
基于这个模式获取的token,需要关闭Azure默认的安全模式。
具体: Azure Active Directory —> 属性 —> 管理安全默认值(设置为否)
2.1、模拟页面登录的模式获取SecurityToken
Endpoint: https://login.microsoftonline.com/extSTS.srf
Method: POST
请求头:
Accept: application/json;odata=verbose
请求体内参数说明:
UserName: 此处填入用户名
Password: 此处填入密码
SharPointAdress: sharepoint 地址,通常为{ {domain}}.sharepoint.com
请求体:
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://login.microsoftonline.com/extSTS.srf</a:To>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken>
<o:Username>{
{UserName}}</o:Username>
<o:Password>ringofor6?</o:Password>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<t:RequestSecurityToken xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
<wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<a:EndpointReference>
<a:Address>{
{SharPointAdress}}</a:Address>
</a:EndpointReference>
</wsp:AppliesTo>
<t:KeyType>http://schemas.xmlsoap.org/ws/2005/05/identity/NoProofKey</t:KeyType>
<t:RequestType>http://schemas.xmlsoap.org/ws/2005/02/trust/Issue</t:RequestType>
<t:TokenType>urn:oasis:names:tc:SAML:1.0:assertion</t:TokenType>
</t:RequestSecurityToken>
</s:Body>
</s:Envelope>
正常响应:
定位
BinarySecurityToken标签即可
<wsse:BinarySecurityToken Id="Compact0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">t=EwDwAk6hBwAUSmCQQlqR5MKj0PCkIZAplWMov+YAARQxiXpNh71Wjd3/I8j7dYLc6v+mmYPhv+MXYG6EHgHk+sgAo23kodTVN5siS9jH7Kc4df29Q4sliRmlCWkXNdEVgrZDgwg60g8Sfu7fwlFBQNEOYhVZltmCUr5VZgU4onTpHAbg9bkiW78tiXUrGD45kpJN7xk+9TpTv10ilolPxhnGh7twe756cBMwUkmSH1d/JL2ddfzXT4nVkVG4IHUavXCIF43CPBYwIJOZZwBseDIqsA9JWxJvwSK+c+Cxoww/y32uZ8flLMKy4WeumgboADqYGxGig/EY0RJDus7DD14ZqB+h9F1H26GSEjc21gH5WtqG4h2990XUSEi2Gw0DZgAACBypP6+DimiUwAH1We5a17tELMluinkxCUxgJZQ043oSTCrqE/lnmjmfkCO1A8LJcdEkQkXb5kP0ecuS9AaOOKQT7hL1Ne1m01WNPJbjOXbXjSX648wiP7sx1s8AfSihrVyJyuyLwTFr1QJZtKZ3fMgL4wYanP6jYaPCzMilL0ef5vq2AatBkaeQbgx65D9S4yXprQneLmZbrlFXt4WYNxsMBka8PU0RrRBeVepKTf+lmVz6+VrInAmWsiCkSyJ5NF9QwtKmgF0KLtWpCO4bzNMakANUHiwS6cQ3aZQ8ZFFUcbJf/TIRWTtWOHUA06PmU5WDvszwS9PBrwb02lqnAP3a2zzq8RRlnsQdpdujfOEv/3wWAx/1iH/FrEWkDy0okEv3tDZjz+ZlMtBMb48Y07WyeWyO+wAKV+PGlhEP9fT4rev/tIa82RX3xf1dRkKsOylK8uhX929tiqNxY7t72JoZG5euarEXljDuLAsGVc7lz2obkJalHIKn9LYqGsxXpkZerk7+R3oQySE4kotyT2iat9+QTvm62+ghRdjF7F90N72NTuPvZAcrICRsOzgRCY0WomZ+SxktXNhSl6mwUEPSQWQ1zRFTUbtELgI=&p=</wsse:BinarySecurityToken>
非正常响应:
通常为出现
53003:Access has been blocked by Conditional Access policies需要关闭默认安全设置,参考第三点第2小点
2.2、获取登录后的cookies
利用securityToken请求这个端点,主要是需要获取请求响应中的cookies,为下一步获取真正的token作准备
Endpoint: https://{ {domain}}.sharepoint.com/_forms/default.aspx?wa=wsignin1.0
Method: POST
请求体参数说明:
直接将第一步获取的
BinarySecurityToken填入请求体即可
请求体:
{
{BinarySecurityToken}}
响应头:
我们需要从响应头中获取
FedAuth
2.3、获取真正的access token
利用上一步获取的cookies值作为请求附带即可
Endpoint: https://{ {domain}}}.sharepoint.com/_api/contextinfo
Method: POST
正常响应:
定位标签:
FormDigestValue就是我们需要定位的token
<?xml version="1.0" encoding="utf-8"?>
<d:GetContextWebInformation xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:type="SP.ContextWebInformation">
<d:FormDigestTimeoutSeconds m:type="Edm.Int32">1800</d:FormDigestTimeoutSeconds>
<d:FormDigestValue>xx9D3C71AF83CA01671A6ECE8A7547BB4A56E33412BCC7541ADB0E8B01B02BE022948F6A341BA8AA0F190DE35EB485124EAB58265D084BF75E8D78B42F5FF8504,13 Jul 2022 02:22:21 -0000</d:FormDigestValue>
<d:LibraryVersion>16.0.22629.12003</d:LibraryVersion>
<d:SiteFullUrl>https://{
{domain}}.sharepoint.com</d:SiteFullUrl>
<d:SupportedSchemaVersions m:type="Collection(Edm.String)">
<d:element>14.0.0.0</d:element>
<d:element>15.0.0.0</d:element>
</d:SupportedSchemaVersions>
<d:WebFullUrl>https://{
{domain}}.sharepoint.com</d:WebFullUrl>
</d:GetContextWebInformation>
3、通用Api操作
前置条件: 获取了access token
类型说明:
我们可以根据接口参数中返回的__metadata-> type 来判断
SP.Folder: 文件夹类型
SP.File: 文件类型
Collection(SP.Social.SocialActor): 社交类内容数据
3.1、获取当前公共目录结构
Endpoint: https://{ {domain}}.sharepoint.com/_api/web/
GetFolderByServerRelativePath(decodedUrl=‘Shared Documents’)Method: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
响应示例:
基于示例边幅过大,简略说明,并不会全部展示
{
"d": {
"__metadata": {
...
"type": "SP.Folder"
},
...
"Exists": true,
"IsWOPIEnabled": false,
"ItemCount": 5,
"Name": "Shared Documents",
"ProgID": null,
"ServerRelativeUrl": "/Shared Documents",
"TimeCreated": "2022-06-25T15:20:17Z",
"TimeLastModified": "2022-07-11T07:25:38Z",
"UniqueId": "e0cebed2-b84a-485d-903e-ab6acb4f77ca",
"WelcomePage": ""
}
}
3.2、获取当前公共目录下的所有文件
Endpoint: https://{ {domain}}.sharepoint.com/_api/web/
GetFolderByServerRelativePath(decodedUrl=‘Shared Documents’)/FilesMethod: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
响应内容:
为方便测试结果:已经在公共目录下创建了一个文件:test.jpg
{
"d": {
"results": [
{
"__metadata":
{
...
"type": "SP.File"
},
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{6B757991-6665-4D33-A96D-A64852C0C6BF},1,2",
"CustomizedPageStatus": 0,
"ETag": "\"{6B757991-6665-4D33-A96D-A64852C0C6BF},1\"",
"Exists": true,
"IrmEnabled": false,
"Length": "13582",
"Level": 1,
"LinkingUri": null,
"LinkingUrl": "",
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "test.jpg",
"ServerRelativeUrl": "/Shared Documents/test.jpg",
"TimeCreated": "2022-07-08T07:25:26Z",
"TimeLastModified": "2022-07-08T07:25:26Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0",
"UniqueId": "6b757991-6665-4d33-a96d-a64852c0c6bf"
}
]
}
}
3.3、获取指定文件讯息
Endpoint: http://{ {domain}}.sharepoint.com/_api/web/GetFileByServerRelativePath(decodedUrl=‘/Shared Documents/test.jpg’)
Method: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
响应内容:
{
"d": {
"__metadata":
{
...
"type": "SP.File"
},
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{6B757991-6665-4D33-A96D-A64852C0C6BF},1,2",
"CustomizedPageStatus": 0,
"ETag": "\"{6B757991-6665-4D33-A96D-A64852C0C6BF},1\"",
"Exists": true,
"IrmEnabled": false,
"Length": "13582",
"Level": 1,
"LinkingUri": null,
"LinkingUrl": "",
"MajorVersion": 1,
"MinorVersion": 0,
"Name": "test.jpg",
"ServerRelativeUrl": "/Shared Documents/test.jpg",
"TimeCreated": "2022-07-08T07:25:26Z",
"TimeLastModified": "2022-07-08T07:25:26Z",
"Title": null,
"UIVersion": 512,
"UIVersionLabel": "1.0",
"UniqueId": "6b757991-6665-4d33-a96d-a64852c0c6bf"
}
}
}
3.4、下载指定文件
Endpoint: http://{ {domain}}.sharepoint.com/_api/web/GetFileByServerRelativePath(decodedUrl=‘/Shared Documents/test.jpg’)/$value
请求头:
Authorization:{ {access token}}
其实就是指令符:$value
3.5、获取关注内容
Endpoint: https://{ {domain}}.sharepoint.com/_api/social.following/my/followed(types=15)
type值是组合值:用户 = 1,文档 = 2,站点 = 4,标签 = 8。允许按位组合Method: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
响应内容:
为方便测试结果:已经创建了一个网站:demo,并于网站下创建了目录demo 及文件test.jpg
{
"d": {
"Followed": {
"__metadata": {
"type": "Collection(SP.Social.SocialActor)"
},
"results": [
{
"ActorType": 2,
"CanFollow": true,
"ContentUri": "https://{
{domain}}.sharepoint.com/sites/demo",
"GroupId": "00000000-0000-0000-0000-000000000000",
"Id": "8.ac0932d648894a7aac1369374c81b689.1d3eddd53113474aa8a84db493774f6d.ac0932d648894a7aac1369374c81b689.00000000000000000000000000000000",
"IsFollowed": true,
"Name": "demo",
"Status": 0,
"TagGuid": "00000000-0000-0000-0000-000000000000",
"Title": "demo",
"Uri": "https://{
{domain}}.sharepoint.com/sites/demo"
},
{
"ActorType": 1,
"CanFollow": false,
"ContentUri": "https://{
{domain}}.sharepoint.com/Shared Documents/demo/test.txt",
"GroupId": "00000000-0000-0000-0000-000000000000",
"Id": "2.ceac4859fce64a628f11637bf654ded7.7b41bbd446cb4244a80eedb78e934726.277493411bb64172b1d0b7741c413aa9.107cab05d2084824a8503c9a451848cd",
"IsFollowed": true,
"Name": "test.txt",
"Status": 0,
"TagGuid": "00000000-0000-0000-0000-000000000000",
"Uri": "https://{
{domain}}.sharepoint.com/Shared Documents/demo/test.txt"
}
]
}
}
}
3.6、获取关注内容数量
Endpoint: https://{ {domain}}.sharepoint.com/_api/social.following/my/followedcount(types=15)
type值是组合值:用户 = 1,文档 = 2,站点 = 4,标签 = 8。允许按位组合Method: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
{
"d": {
"FollowedCount": 2
}
}
3.7、获取关注内容公共目录结构
与获取本身公共目录差异仅仅是增添
关注目录的相对地址(为了便于展示示例,这里存在一个网站demo,已关注。)EndPoint: https://{ {domain}}.sharepoint.com/sites/demo/_api/web/GetFolderByServerRelativePath(decodedUrl=‘Shared Documents’)
Method: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose
响应内容
响应内容与
3.1结构一致
3.8、其他关注内容操作(通用)
其实与公共目录相差异的部分就是:增添
关注目录的相对地址①获取关注内容的目录所有文件
Endpoint:
{ {SharePointAdress}}/sites/demo/_api/web/GetFolderByServerRelativePath(decodedUrl=‘Shared Documents’)/Files②获取关注内容文件
Endpoint:
{ {SharePointAdress}}/sites/demo/_api/web/GetFolderByServerRelativePath(decodedUrl=‘Shared Documents/test.jpg’)③下载关注内容文件
Endpoint:
{ {SharePointAdress}}/sites/demo/_api/web/GetFolderByServerRelativePath(decodedUrl=‘Shared Documents/test.jpg’)/$valueMethod: GET
请求头:
Authorization:{ {access token}}
Accept: application/json;odata=verbose (下载部分不需要这个请求头)
边栏推荐
- 2022广东省安全员A证第三批(主要负责人)练习题及模拟考试
- 【回归预测】基于粒子滤波实现锂离子电池寿命预测附matlab代码
- Magic Usage of mongodb $symbol +mongo data type
- Build an embedded development environment
- Why are the special effects in others' games very soft
- 【CTF】pwn2_ sctf_ two thousand and sixteen
- android 数据库左连接查询
- id Tech5的MegaTexture技术
- JSON under mysql8
- 2022 Shanghai safety officer C certificate national question bank and answers
猜你喜欢

Authing 实践|制造业身份认证统一管理解决方案

VMware中扩展硬盘

LeetCode 0116. Populate the next right node pointer for each node

idea按条件断点调试

QR分解求矩阵逆--c工程实现

cut,sort,uniq,xargs

sql server建表时设置ID字段自增 (navicat 演示)
![[Hongke] lidar safety system: making the world safer](/img/35/23986a66c63d51862c7562834d6a89.png)
[Hongke] lidar safety system: making the world safer

Scratch reverse order output electronic society graphical programming scratch grade examination level 4 true questions and answers analysis June 2022

最新水果FLStudio20.9低版本版升级高版本教程
随机推荐
ES6 learning function (strict mode, higher-order function, closure)
【LeetCode】通用操作总结
mongodb $符号的神奇用法+mongo数据类型
Translucent double glass side thickness
mysql 初始化修改密码问题
freeswitch的话单模块
2022年P气瓶充装考试练习题模拟考试平台操作
Linear regression + basic optimization of deep learning
【虹科】激光雷达安全系统:让世界更安全
Block 的分类
Zero basic C language
Programming in the novel [serial 12] the moon bends in the yuan universe
vscode下载历史版本
Nacos 新建配置管理
Binary installation MySQL initialization password problem
Expanding hard disk in VMWare
Xgen hair guide history cleared solution
Google Play应用商店可能会删除应用权限概述 转而使用新的数据安全信息组合
Cocos shader basics 7
[handwritten numeral recognition] handwritten numeral recognition based on lenet network with matlab code