client_secret 刷新令牌 azure b2c 不需要

client_secret not required on refresh token azure b2c

我有一个 azure b2c 应用程序。当我通过 portal.azure.com 中的用户应用程序创建用户时(或使用 postman 发出 post 请求)我必须发送我的 b2c 应用程序的 client_secret 来刷新令牌。 但是对于通过 Powershell 使用 azureAD 模块创建的用户,我有一个错误提示我不应该发送 client_secret.

{
    "error": "invalid_request",
    "error_description": "AADB2C90084: Public clients should not send a client_secret when redeeming a publicly acquired grant.\r\nCorrelation ID: 39abec35-770c-42e6-bd65-438d6501a124\r\nTimestamp: 2018-04-09 14:43:13Z\r\n"
}

为什么会有这种差异?我该如何使用图表 api?

创建不需要 client_secret 的用户

提前致谢! 德语

根据报错信息,我假设你使用的App是一个Native app(正如juunas所说,Powershell也是一个native app),这也在 Oauth 中称为 public 客户端。 client_secret 仅当您的应用程序是 Web App/API 时才需要,这在 Oauth 中也称为机密客户端。

正在使用 本机应用刷新访问令牌:

// Line breaks for legibility only

    POST /{tenant}/oauth2/token HTTP/1.1
    Host: https://login.microsoftonline.com
    Content-Type: application/x-www-form-urlencoded

    client_id=6731de76-14a6-49ae-97bc-6eba6914391e
    &refresh_token=OAAABAAAAiL9Kn2Z27UubvWFPbm0gLWQJVzCTE9UkP3pSx1aXxUjq...
    &grant_type=refresh_token
    &resource=https%3A%2F%2Fservice.contoso.com%2F

NOTE: The application secret that you created in the app registration portal for your app. It cannot be used in a native app (public client), because client_secrets cannot be reliably stored on devices. It is required for web apps and web APIs (all confidential clients), which have the ability to store the client_secret securely on the server side.

因此,您只需删除请求正文中的client_secret即可解决。

另外,Azure AD B2C 不支持 client_credentials 流程。查看有关此 .

的详细信息