Cannot authenticate with SSO between multiple web apps with Azure B2C and MSAL.js Angular

We are building multiple web applications that use Azure B2C user flows for authentication. They are hosted on our servers within the same domain, but different subdomains to differentiate them. The tech stack varies a bit between the apps, but for now, let’s focus on two that are both based on Angular. We have configured the apps and their respective APIs to be authenticated via a single Azure B2C sign-in policy using the MSAL.js node package, and taken individually, they authenticate and work just fine (well, mostly, but that’s another issue all together). Our issue is that, based on how we understand Azure B2C to handle SSO, a user should be able to sign-in to one app, and move seamlessly to the other app without having to sign-in again, but that is not the case. Switching to the other app shows that the user is not signed in and is prompted with the login page if they attempt any tasks that require authorization, and that is not the behavior we want.

To better understand MSAL.js and to remove any implementation discrepancies that might cause an issue, I followed this tutorial from Microsoft Learn to setup a sample Angular app that authenticates with B2C: https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-angular-spa-app

Since the sample app listed in the tutorial is archived, I used this one instead, but I otherwise followed the tutorial to a T:
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-v3-samples/angular-b2c-sample-app

I duplicated the code (both the web app and the web API) so that we had two identical yet separate web apps, changing only the config values.

Within our Azure B2C settings in the Azure Portal, I registered both the web app and API for each of the app instances (a total of four app registrations), modifying settings like Redirect URI to match the separate instances, but otherwise sticking to the tutorial instructions (later I tried to see if I pointed both app instances to the same app registration, i.e. same client ID, would help, but no such luck).

I run both of the web apps and APIs locally and navigate to the first instance in my browser (via http://localhost:4200). I sign in and am able to see my user claims on the page. Great. In the same tab (or different, it doesn’t seem to matter), I navigate to the localhost port of the second instance, and I am not logged in. I can sign in just as well, but the two sessions seem entirely disconnected from each other. And for the record, if I open up the same app in different tabs, and sign-in/out of one, the other automatically refreshes to match, which is how I imagine the SSO between the separate app instances is supposed to work, but it just doesn’t.

And just to be extra sure, I ran the same test using the sample B2C instance specified in the sample app instead of our own B2C instance, and it worked. I did have to press the login button again when I navigated to the second app instance, but it authenticated me without prompting me to login, which tells me that there’s something about the way our B2C is configured as opposed to anything to do with the client-side code.

I’ve also been referring to this Microsoft Learn page concerning SSO with MSAL.js: https://learn.microsoft.com/en-us/entra/identity-platform/msal-js-sso

I’ve tried seeing if I just call the ssoSilent method before loginPrompt does something, but I just get this error message in the browser console.

Image of SSO error in browser console

Error: Uncaught (in promise): InteractionRequiredAuthError: interaction_required: AAB2C90077: User does not have an existing session and request prompt parameter has a value of 'None.

As I understand, the prompt parameter doesn’t need a value because it is a SSO silent request, but the important thing is that it does not recognize my existing session.

With that said, I do have some specific questions:

  1. If we want to maintain SSO in this way, do all of our apps need to be registered individually in Azure B2C, or should they be registered together under the same client ID? We started with separate registrations, but sharing a single registration between multiple sites did not seem to help.
  2. Do the apps having different subdomains but the same domain (i.e. app1.mywebsite.com and app2.mywebsite.com) make a difference? I would think not, but the documentation I’ve read seems unclear. Anyway, my recent tests on localhost seem to rule this out as a factor, but the apps do have separate port numbers, so maybe that makes a difference? I don’t know.

I know I haven’t said much about how our B2C user flows and app registrations are set up, but most everything of concern uses the out-of-the-box settings. I can share more details as requested (censoring personal details, of course).

Please let me know if you have any suggestions or questions. We’re still trying to get acclimatized to Azure B2C. Thanks.

New contributor

user25230787 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật