rest - 对 Azure AD 进行非交互式身份验证,以在 Sharepoint Project Server 上进行 CRUD 操作
问题描述
我需要连接到 Sharepoint OData 来执行一些 CRUD 操作(来自 SAP C4C)。
API 端点是 https://{tenant}.sharepoint.com/sites/{Site}/_api/ProjectServer/Projects
我能够使用 grant_type=client_credentials 和证书创建一个执行 JWT 的令牌(请参阅https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant -flow ) 但我无法访问 ProjectServer/Projects 上的数据。错误是这样的:
{
"error": {
"code": "-1, System.Web.Services.Protocols.SoapException",
"message": {
"lang": "en-US",
"value": "ProjectServerError(s) LastError=GeneralNotLicensed Instructions: Pass this into PSClientError constructor to access all error information"
}
}
}
我认为我需要与用户一起向 Azure AD 进行身份验证,但如果没有用户的交互,我找不到一种好方法。
我尝试了密码授予流程(grant_type=password 使用服务用户),但它似乎不起作用(令牌端点给我一个错误:“AADSTS70002:验证凭据时出错。AADSTS50126:用户名或密码无效”)。
我无法从我正在使用的平台访问任何 azure 连接器,因此我必须手动执行所有操作...
有人有什么想法吗?
谢谢。
编辑:
如果有用,我附上密码授权调用:
URL: https://login.microsoftonline.com/{tenant_GUID}/oauth2/token
Content-Type: application/x-www-form-urlencoded
grant_type=password
scope=openid {clientid} offline_access
resource=https://{tenant}.sharepoint.com
client_id={clientId}
username={user}@hosttenant.com
password=password
回应是:
{
"error": "invalid_grant",
"error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: XXXXXXXXXX\r\nCorrelation ID: XXXXXXXX\r\nTimestamp: 2018-08-27 15:36:50Z",
"error_codes": [
70002,
50126
],
"timestamp": "2018-08-27 15:36:50Z",
"trace_id": "XXXXXXXXXXXXXX",
"correlation_id": "XXXXXXXXXXXXXX"
}
解决方案
推荐阅读
- azure-devops - Azure Dev Build Release 测试执行被中止
- python - 如何使用 Python 以不同的名称保存从客户端服务器接收到的文件
- javascript - 如何使用 CSS 或 jQuery 选择元素内的纯文本?
- python - 函数定义有问题
- node.js - 有没有办法保护 API 路由不被发出请求的应用程序之外的经过身份验证的用户击中?
- android - 只有一个用户可以通过 Android SQLite 进入登录
- javascript - JavaScript 数据转换问题
- c# - 如何为 C# 桌面应用程序设置默认时区?
- c - 为什么我的凯撒密码程序执行时会出错?
- python - 什么是 Python 中的分类器(高斯朴素贝叶斯)?