我已遵循此处的入门工作流程: https://learn.microsoft.com/azure/active-directory-b2c/active-directory-b2c-get-started-custom
我从头开始执行了两次,并且在尝试使用登录和注册自定义策略登录时,两次都收到“您的密码不正确”的提示。如何正确验证?
正在运行的事情:
- 当我注册时,用户旅程就完成了,并且用户被添加到目录中
- 使用内置政策,我可以登录并注册
- 使用内置策略,我可以使用我使用自定义策略注册的用户进行登录
使用 Application Insights 我可以看到以下错误。 (采取了一些卫生措施)
"ValidationRequest":{
"ContentType":"Unspecified",
"Created":"2017-10-06T17:19:34.3995426Z",
"Key":"ValidationRequest",
"Persistent":true,
"Value":"client_id=55555555-5555-5555-5555-555555555555&resource=cccccccc-cccc-cccc-cccc-cccccccccccc&username=MYUSERNAME&password=PASSWORDIENTEREDONSCREEN&grant_type=password&scope=openid&nca=1;1;login-NonInteractive;False"
},
"ValidationResponse":{
"ContentType":"Json",
"Created":"2017-10-06T17:19:34.3995426Z",
"Key":"ValidationResponse",
"Persistent":true,
"Value":"{\"error\":\"invalid_client\",\"error_description\":\"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.\\r\\nTrace ID: 55555555-cccc-cccc-cccc-555555555555\\r\\nCorrelation ID: 77777777-7777-7777-7777-777777777777\\r\\nTimestamp: 2017-10-06 17:19:33Z\",\"error_codes\":[70002],\"timestamp\":\"2017-10-06 17:19:33Z\",\"trace_id\":\"55555555-cccc-cccc-cccc-555555555555\",\"correlation_id\":\"77777777-7777-7777-7777-777777777777\"};1;login-NonInteractive;False"
},
重要的一点似乎是:
"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion"
后来又说:
"Exception of type 'Web.TPEngine.Providers.BadArgumentRetryNeededException' was thrown."
我已经仔细检查过一些事情:
- 在我的身份体验框架 > 策略 key 中,按照指南中的步骤操作后,我有以下 4 个 key :
- B2C_1A_AdminClientEncryptionKeyContainer
- B2C_1A_FacebookSecret
- B2C_1A_TokenEncryptionKeyContainer
- B2C_1A_TokenSigningKeyContainer
- 在常规 AAD > 应用程序注册中,我有以下应用程序:
- 身份体验框架
- ProxyIdentityExperienceFramework
- 并且 ProxyIdentityExperienceFramework 已从 IdentityExperienceFramework 委派访问 IdentityExperienceFramework 权限。
- 我已经为这两个应用程序点击了“授予权限”。
- 两个应用程序 ID 均在 TrustFrameworkExtensions.xml 中正确替换,各替换两个位置
非常感谢任何帮助。谢谢。
最佳答案
您的 ProxyIdentityExperienceFramework 应用被错误地创建为 Web 应用/API。您需要将其重新创建为 native 应用。确保不要忘记将基本策略中的 client_ids 相应更新为新的 ProxyIdentityExperienceFramework。
当您尝试使用注册为 Web 应用/API 的应用程序的 client_id 获取 token 时,会出现错误 AADSTS70002:请求正文必须包含以下参数:'client_secret 或 client_assertion但没有提供所需的 client_secret。对于 native 应用程序,不需要 client_secret。
登录时,Azure AD B2C 的信任框架(执行自定义策略的框架)在内部尝试使用 ProxyIdentityExperienceFramework 应用( native 应用)获取 IdentityExperienceFramework 应用 (Web API) 的 token 。如果您错误地将后者创建为 Web 应用程序/API,B2C 的策略引擎将无法获取 token ,这会向用户显示您的密码不正确错误消息。
关于Azure B2C 示例自定义策略,登录时显示 'Your password is incorrect',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46611968/