Azure MSAL JS : How to edit profile?

标签 azure azure-ad-b2c msal.js

我已成功为 Azure AD B2C 实现 MSAL JS。 下一步是让用户编辑他们的个人资料。我为编辑个人资料创建了新策略。 但如何将用户重定向到那里呢?只有登录方法/获取 token 方法。 我尝试将权限设置为不同的策略。然后它确实重定向到正确的页面,但随后它开始提示范围中的错误,并且它在本地弄乱了 token 。

editProfile() {
  this.userAgentApp.authority = this.policyEditProfile;
  this.userAgentApp.loginRedirect();
}

ASP.NET 代码示例明确具有设置 editProfile 策略 ID 的选项:https://learn.microsoft.com/en-gb/azure/active-directory-b2c/active-directory-b2c-devquickstarts-web-dotnet-susi#update-code-to-use-your-tenant-and-policies

感觉 MSAL.JS 中缺少此内容,我必须手动创建 URL,对吗?

最佳答案

是的,这是正确的。您将需要使用不同的机构,其 URL 由租户和策略名称组成,如 here 所示。 :

private static string Tenant = "yourTenant.onmicrosoft.com";
public static string PolicySignUpSignIn = "b2c_1_susi";
public static string PolicyEditProfile = "b2c_1_edit_profile";
private static string BaseAuthority = "https://login.microsoftonline.com/tfp/{tenant}/{policy}/oauth2/v2.0/authorize";
public static string Authority = BaseAuthority.Replace("{tenant}", Tenant).Replace("{policy}", PolicySignUpSignIn);
public static string AuthorityEditProfile = BaseAuthority.Replace("{tenant}", Tenant).Replace("{policy}", PolicyEditProfile);

顺便说一句,该示例虽然针对 .NET Desktop 显示了如何使用编辑配置文件密码重置策略:active-directory-b2c-dotnet-desktop ,特别参见 EditProfileButton_Click方法中,获取 token (交互式)的因素将触发编辑配置文件的对话框:

AuthenticationResult authResult = await App.PublicClientApp.AcquireTokenAsync(App.ApiScopes, GetUserByPolicy(App.PublicClientApp.Users, App.PolicyEditProfile), UIBehavior.SelectAccount, string.Empty, null, App.AuthorityEditProfile);

关于Azure MSAL JS : How to edit profile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45588004/

相关文章:

azure - 在 azure 计算机上连接 Power BI 企业网关时出错

vb.net - Azure Active Directory B2C - AADB2C - AADB2C90079 : Clients must send a client_secret when redeeming a confidential grant

azure - 在 Postman 中请求受 Azure AD B2C 保护的 Azure 函数应用程序的访问 token

azure-ad-b2c - 休息 API 超时

使用 React SPA 的 msal token 超时

Azure Log Analytics - 查询 Application Insight 自定义指标

azure - 我是否使用 Azure 表存储或 SQL Azure 作为我们的 CQRS 读取系统?

Azure 广告 B2C IDX20804 : Unable to retrieve document from

angular - 如何在 MSAL for Angular 中的访问 token 过期时重定向用户?

azure - 用户关闭并重新打开浏览器后,需要使用 Azure AD B2C 重新进行身份验证