• Welcome to LiuJason's Blog!

不借助第三方,使用微软官方API获取世纪互联sharepoint站点siteid

Web项目 Jason 3 years ago (2020-10-27) 685 Views 0 Comments QR code of this page
文章目录[隐藏]

前言

之前转载了一下如何用rclone挂载世纪互联版的OneDrive:https://www.liujason.com/article/830.html
但是除了OneDrive之外,SharePoint也是很好的数据载体。
SharePoint在使用上比起OneDrive麻烦的一点是需要获取到siteid,一般都通过第三方的服务去获取,这样有安全隐患。

详细操作步骤

完成身份认证

首先找到一个合适的api开发工具,我这里用的是免费的postman:

The Collaboration Platform for API Development
Simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

打开后进行授权,添加一个Oauth2的授权,并要求获取token:

然后点击【Get Access Token】设置的时候设置如下信息,我用的是云筏的信息,其他的自行替换掉:

Auth URL
https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize

Access Token URL
https://login.chinacloudapi.cn/common/oauth2/v2.0/token

#Client ID和Client Secret参考文章开头的那个链接

Scope
Files.Read Files.Read.All Files.Read.Selected Files.ReadWrite Files.ReadWrite.All Files.ReadWrite.AppFolder Files.ReadWrite.Selected

Client Authentication
Send as basic auth header

然后就会跳转到世纪互联的登录页面,登录完成之后即可正常使用graphAPI了!

获取siteid

在Get地址栏输入https://microsoftgraph.chinacloudapi.cn/v1.0/sites/cloudraft.sharepoint.cn:/sites/SP001?$select=id
其中cloudraft改成自己的域名,SP001改成自己的SharePoint站点名
点击Send之后就会有类似如下的信息:

{
    "@odata.context": "https://microsoftgraph.chinacloudapi.cn/v1.0/$metadata#sites(id)/$entity",
    "id": "cloudraft.sharepoint.cn,xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx,xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
}

这个就是siteid,大功告成


This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/1033.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址