http 400: size of header request is too long when signing in user using Multifactor authentication

4.6k views Asked by At

I am trying out the Azure AD-B2C. The user signup/sign in is fine when the MFA is turned off. But when I turn it on, and the user tries to sign in and provides the phone number, and requests a text message by clicking "send code", I get the Http 400 error: size of request headers is too long. Anybody else have this issue?

3

There are 3 answers

3
Saca On BEST ANSWER

The error HTTP 400: Size of header request is too long generally happens because there's too many cookies.

Azure AD B2C's login goes through login.microsoftonline.com, as does almost every Microsoft service (O365, Azure, etc). So if you've got several accounts that you've signed in to across these services, you're accumulating cookies that will cause this problem.

Clearing the cookies should resolve this problem. If this is happening on a recurring basis, you should edit your question to include details about the request and cookies in order to best figure out what's bloating the request and how to reduce it.

0
Larry Aultman On

Short answer: The file with the custom UI was not found by Microsoft login service. After getting shipped around it resulted in the error.

I had the same error with AAD B2C but "cookies" was not the problem. In my case I got the error while testing in the Azure B2C portal checking the policies and the custom UI pages. We use Azure Blob storage to hold custom login setup, its fast and it scales without our attention. The problem was found by using my test website using the B2C service. I put a stop/break on the Account controller's "public Task OnRemoteFailure(RemoteFailureContext context)" method. The debugger message gave me the full context of the error, an http 404 error and it gave the file name it was trying to find. Blob storage is case sensitive. The setup configuration used to configure B2C has camelCase names. The group who created the actual UI customization uses all lower case names. It took someone with access to all the assets to find the simple case name issue. Errors in distributed systems can be difficult.

0
Ryan Wilson On

We just encountered this issue today and I wanted to add this in case it is helpful.

  1. Once you log into the Azure Portal, go to - Azure Active Directory - App Registrations - {Your application} - Manifest

  2. Scroll down until you find the property: groupMembershipClaims

  3. In our case, this was set to "All" on the application which was throwing the 400 error about the request header(s) being to large.

Solution

Changed the manifest to hold a value of "DirectoryRole, ApplicationGroup" but this could be modified to hold whatever you deem necessary for your application. "All" was producing a cookie that was very large if the user belonged to many user groups, once this change was made in Azure, I had to clear my browser cookies and re-authenticate and all worked with no issues.