【发布时间】:2021-08-31 09:22:06
【问题描述】:
Azure Active Directory B2C 用户密码验证
获取Azure AD b2c auth token 的方法是什么?
尝试使用 Microsoft.Identity.Client 获取访问令牌。
代码:
var appId = "<applicationId/ClientId>";
var b2cAuthority = "https://<applicationUrl>/tfp/<applicationUrl>/<userFlow>";
var b2cScopes = new[] { "<readScope>" };
var tenantId = "<tenantId>";
var userLogin = "<login>";
var userPassword = "<password>";
SecureString securePassword = new NetworkCredential("", userPassword).SecurePassword;
var msalPublicClient = PublicClientApplicationBuilder
.Create(appId)
.WithB2CAuthority(b2cAuthority)
.WithTenantId(tenantId)
.Build();
AuthenticationResult authResult = await msalPublicClient
.AcquireTokenByUsernamePassword(b2cScopes, userLogin, securePassword)
.WithClaims("emails")
.ExecuteAsync(CancellationToken.None)
.ConfigureAwait(false);
在 .ExecuteAsync() 上抛出异常:AADB2C90108: The orchestration step '1' does not specify a CpimIssuerTechnicalProfileReferenceId when one was expected
有没有什么办法解决这一问题?
我们不想更改任何默认策略来修复它。
【问题讨论】:
-
您是否使用自定义策略? ROPC 流程?
-
@rbrayb 没有自定义政策
-
@VladyslavFurdak,你设法让它工作了吗?我有完全相同的问题...
标签: azure azure-active-directory azure-ad-b2c