2017-08-09 18 views
15

我已成功实施MSAL JS for Azure AD B2C。 下一步是让用户编辑他们的个人资料。我为编辑个人资料创建了一项新政策。 但如何将用户重定向到那里?只有登录方法/获取令牌方法。 我试图将权限设置为不同的策略。然后它重定向到正确的页面,但是它开始抱怨范围中的错误,并且它在本地混淆了令牌。Azure MSAL JS:如何编辑配置文件?

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

的ASP.NET代码示例明确有一个选项来设置editProfile政策ID:https://docs.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,是正确的?

回答

6

是的,这是正确的。您将需要使用的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); 

BTW,该样本,虽然.NET桌面展示了如何使用编辑个人资料密码重置政策:active-directory-b2c-dotnet-desktop,看到特别是EditProfileButton_Click方法,获得令牌的因素(交互)将触发对话框来编辑配置文件:

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

感谢这个!我已经在MSAL.JS中试过了,但是我得到这个异常? this.userAgentApp.acquireTokenPopup(authSettings.scopes,this.policyEditProfile)。然后((的accessToken)=> { this.setAuthenticated(的accessToken); },(误差)=> { console.error(误差); }) AADB2C90055:请求中提供的作用域'openid配置文件'必须指定一个资源,例如'https://example.com/calendar.read'。 相关ID:8a022666-3400-4d7d-A847-f8dc4dc49452 时间戳:2017年8月13日23:42:10Z :INVALID_REQUEST – Boland

+0

我使用的是相同的范围登录时为我为什么要等编辑配置文件的范围? – Boland