title: Azure B2C React (Frontend) + .net core (Backend) User/Identity/Claims in HttpContext is null
body: <p>Summary</p>
  <p>I try to implement Azure AD B2C authentication in our project. We have a react Frontend and a .net core Backend (REST API's).</p>
  <p>How it should be:</p>
  <ol>
  <li>Open Frontend -&gt; Redirect to microsoft b2c site (works)</li>
  <li>Enter credential and get the token from Azure B2c (works)</li>
  <li>Redirect to our Frontend (works)</li>
  <li>Call a REST API on the Backend (works) I can see the token in the HttpContext Header (see Link &quot;Token in Header&quot;) so the token will be delivered from our frontend to the backend properly.
  <a href="https://i.stack.imgur.com/ToepY.png" rel="nofollow noreferrer">Token in Header</a></li>
  <li>Gets the Identity and claims information out of the httpContext. <strong>(doesn't work).
  -&gt; The user is not set property, no Identity, no claims, nothing (see Link &quot;User Identity/Claims&quot;)</strong>
  <a href="https://i.stack.imgur.com/x4AN4.png" rel="nofollow noreferrer">User Identity/Claims</a></li>
  </ol>
  <p>This my Startup.cs configuration. -&gt; This is the example from Microsoft on github with b2c configuration.</p>
  <pre><code>            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context =&gt; true;
                options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
                // Handling SameSite cookie according to https://docs.microsoft.com/en-us/aspnet/core/security/samesite?view=aspnetcore-3.1
                options.HandleSameSiteCookieCompatibility();
              });
  
              // Configuration to sign-in users with Azure AD B2C
              services.AddMicrosoftIdentityWebAppAuthentication(Configuration, &quot;AzureAdB2C&quot;);
              services.AddControllers();
  
              //Configuring appsettings section AzureAdB2C, into IOptions
              services.AddOptions();
              services.Configure&lt;OpenIdConnectOptions&gt;(Configuration.GetSection(&quot;AzureAdB2C&quot;));
  </code></pre>
  <p>This is my token which I get from Azure AD B2c. (see Link &quot;Token&quot;) <a href="https://i.stack.imgur.com/dTwjW.png" rel="nofollow noreferrer">Token</a></p>
  <p>This is my application setting (see Link &quot;Settings&quot;) <a href="https://i.stack.imgur.com/r3N4z.png" rel="nofollow noreferrer">Settings</a></p>
  <p>I also tried this -&gt; <a href="https://stackoverflow.com/questions/49468422/azure-ad-b2c-token-returns-name-but-user-identity-name-is-null/49500214">Azure AD B2C Token returns name but User.Identity.Name is null</a>
  But doesn't work.</p>
  <p><strong>Can Some tell me what I am doing wrong? Why is the User Identiy/Claims always null?</strong></p>
  <p>React code for axios calls handling. Adding the token to the header:</p>
  <pre><code>export function buildHTTPHeaders(config: AxiosConfig) {
      const headers: { [key: string]: string } = {
          Accept: CONTENT_TYPE,
          'Content-Type': CONTENT_TYPE,
      };
  
      const apiToken = sessionStorage.getItem('msal.idtoken');
  
      const auth = apiToken ? `Bearer ${apiToken}` : config.authorization;
      if (auth) {
          headers['Authorization'] = auth;
      }
  
      return headers;
  }
  
  export const getApiBaseURL = () =&gt; temporaryStaticConfig.API_BASE_PATH;
  
  export function getAxios(config: AxiosConfig = { throwNotFoundException: false }) {
      const { dispatch, getState } = store;
  
      const instance = Axios.create({
          validateStatus: validateStatus(dispatch, getState),
          baseURL: getApiBaseURL(),
          headers: buildHTTPHeaders(config),
      });
      instance.interceptors.response.use(transformNotFound(config.throwNotFoundException));
  
      return instance;
  }
  </code></pre>