title: Azure AD B2C Single Page App Roles
body: <p>We are trying to integrate Azure AD B2C into a SPA.  We want to include Roles in the ticket so that we can use AuthorizeRoles &amp; IsInRole in the api.  We have looked at a couple of examples.</p>
  
  <p><a href="https://github.com/Azure-Samples/active-directory-b2c-dotnet-webapp-and-webapi" rel="nofollow noreferrer">Example 1</a></p>
  
  <p><a href="https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp" rel="nofollow noreferrer">Example 2</a></p>
  
  <p>The first example isn't a SPA and doesn't include roles.  It is accepted that including membership &amp; groups in the ticket using Azure AD B2C isn't supported as per below link.</p>
  
  <p><a href="https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/10123836-get-user-membership-groups-in-the-claims-with-ad-b" rel="nofollow noreferrer">Azure AD B2C Group Membership Feature Feedback</a></p>
  
  <p>The workaround as suggested above seems to be to use the "OnAuthorizationCodeReceived" event as per below to inject/add your own Role claims to the ticket.</p>
  
  <p><a href="https://stackoverflow.com/questions/45885795/azure-ad-b2c-role-management">Workaround</a></p>
  
  <p>The issue we have is that we are using a SPA so we need to follow example 2, we also need to be able to add our own manged roles into the ticket which isn't a supported feature but Microsoft have said there is a workaround as shown.  The workaround however doesn't work with MSAL.js as in example 2.</p>
  
  <p>How can we include our own managed Roles into the ticket using the MSAL.js library so we can integrate Azure AD B2C into our SPA enabling us to use AuthorizeRoles &amp; IsInRole in the api?</p>