首页 > 解决方案 > 对 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"
}

标签: restazuresharepoint

解决方案


推荐阅读