【问题标题】:Access sharepoint\office 365 using CSOM and grant_type=client_credentials使用 CSOM 和 grant_type=client_credentials 访问 sharepoint\office 365
【发布时间】:2021-06-25 12:00:14
【问题描述】:

我已按照此示例中的说明进行操作: https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/using-csom-for-dotnet-standard 并且可以很好地连接:-) 使用grant_type=password、用户名和密码

但是我想使用客户端 ID 和客户端密码进行连接... I have set these up in AzureAD

i have added the permissions:

i have exposed the api

this is the body of my request

at this point in the code i actually receive the token

but here it fails with a 401

我想知道是否有人有这个工作的例子?

我也试过这个https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs 根据 2018 年 11 月 7 日停用的文档,我可以让它工作。

我不确定它使用什么身份验证方法或如何识别身份验证方法。

【问题讨论】:

    标签: sharepoint azure-active-directory office365 csom


    【解决方案1】:

    如果此注册仅用于 SharePoint,则无需公开 API。

    您不需要范围。您需要像下面一样传入“client_id”和“resource”,获取令牌以调用 SharePoint:

    client_id: [appRegistrationClientId]@[tenantid]
    Resource: 00000003-0000-0ff1-ce00-000000000000/[tenant].sharepoint.com@[tenant-id]
    

    这也会有所帮助:https://anexinet.com/blog/getting-an-access-token-for-sharepoint-online/

    【讨论】:

    • 嗨,Brian,我很欣赏这个信息,是的,这个例子有效,但是如果需要,我们也希望使用 openid,ms g​​raph federation ws-federation saml-p
    • 嗨,Brian,我很欣赏这个信息,是的,这个例子有效,但是如果需要,我们也希望使用 openid、ms graph、federation、ws-federation、saml-p,因为这些都列在具有简单配置更改的 Azure AD。根据我的问题第 1 行中链接的示例文档,我们还可以连接“grant_type=password”而不是“grant_type=client_credentials”,这似乎很奇怪??
    猜你喜欢
    • 2020-10-09
    • 1970-01-01
    • 2014-08-04
    • 1970-01-01
    • 2018-10-04
    • 2015-05-06
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多