代码之家  ›  专栏  ›  技术社区  ›  Dan H

grant\u类型密码要求设置客户端id

  •  0
  • Dan H  · 技术社区  · 8 年前

    我正在设置asp。net core 2 web api使用IdentityServer4,由于某些现有客户的原因,我需要支持资源所有者密码凭据授予。我在获取令牌时遇到问题,因为它显示“找不到客户端标识符”。

    此操作失败。。。

    Content-Type: application/x-www-form-urlencoded 
    grant_type=password&username=myuser&password=mypassword
    

    此操作成功。。。

    Content-Type: application/x-www-form-urlencoded 
    grant_type=password&username=myuser&password=mypassword&client_id=ro.client
    

    为什么我需要添加client\u id才能工作?OAuth 2.0规范没有指定需要它- https://www.rfc-editor.org/rfc/rfc6749#section-4.3

    1 回复  |  直到 5 年前
        1
  •  1
  •   Community Mohan Dere    5 年前

    如果客户类型为机密客户或客户已被发布给客户 凭据(或分配的其他身份验证要求) 客户端必须按照所述向授权服务器进行身份验证 在第3.2.1节中- https://www.rfc-editor.org/rfc/rfc6749#section-4.3

    请求涉及一个模拟用户的客户端,IdentityServer始终需要知道哪个客户端正在发出请求,以便能够对其进行授权(例如,验证请求的作用域,甚至可能对其进行身份验证)。

    我在这里使用IdentityServer。我不知道在任何情况下,我希望ROPC拨款类型的公共访问权限。你…吗?

    此外,请不要使用ROPC拨款类型,这是2018年的杜德: https://www.scottbrady91.com/OAuth/Why-the-Resource-Owner-Password-Credentials-Grant-Type-is-not-Authentication-nor-Suitable-for-Modern-Applications