我无法使用 Postman 对 Sharepoint Online 进行 API 调用。我已经成功地对 Graph API 进行了 API 调用,所以我熟悉我认为这应该如何工作。
我已按照以下说明进行设置:
- 用于创建证书和注册 v1 azure 应用程序: https ://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
- 使用客户端凭据流:https ://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow
- 用于创建客户端断言:https ://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials
第一篇文章说它不会接受使用客户端密码生成的访问令牌,但我已经生成了带有密码和证书的令牌,并且没有发现任何区别。
调用任何东西时,例如:
https://<tenant>.sharepoint.com/_api/web
我得到错误:
{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}
这是我使用 v1 /token 端点生成的访问令牌示例:
{
"aud": "https://microsoft.sharepoint-df.com/",
"iss": "https://sts.windows.net/462c0b***********c3708/",
"iat": 1569243291,
"nbf": 1569243291,
"exp": 1569247191,
"aio": "42FgYDiXt***********==",
"app_displayname": "T***********n",
"appid": "00c***********2b",
"appidacr": "2",
"idp": "https://sts.windows.net/46***********708/",
"oid": "2f8a5***********684",
"roles": [
"User.ReadWrite.All",
"TermStore.Read.All",
"Sites.FullControl.All"
],
"sid": "5ab8d57***********0bc",
"sub": "2f8a5***********684",
"tid": "462c0***********708",
"uti": "aHt8d***********9AA",
"ver": "1.0"
}