Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Portal: Bad Request - Request Too Long

I just received the following error when I tried to run a built-in b2c edit policy from portal.azure.com. I have 2 tabs of the portal open. Why am I receiving this error?

Bad Request - Request Too Long HTTP Error 400. The size of the request headers is too long.

Note: I experienced this same error message when testing active-directory-b2c-dotnet-webapp-and-webapi sample project. The reason provided was I was sending too many cookies. Is it the same problem?

If it is the same problem, shouldn't stale cookies be deleted before creating new ones?


I do see a lot of cookies for https://login.microsoftonline.com

chrome cookies node

screen shot 1 of cookies screen shot 2 of cookies

like image 625
spottedmahn Avatar asked Sep 07 '17 15:09

spottedmahn


People also ask

How do I fix bad requests too long?

This issues is usually caused by a corrupted cookie that is too long. Clear the Cache and remove the Cookies for websites that cause problems via the "3-bar" Firefox menu button (Options/Preferences). If clearing cookies didn't help then it is possible that the cookies.

How do I get rid of bad request header fields too long?

If you see the following error when trying to log into University Services with Google Chrome: Bad Request - Request Too Long HTTP Error 400 Try the following: Clear the browser cache completely. Clear the browser cookies. Restart the browser and try again.

What does Bad Request request too long mean?

Bad Request - Request Too Long - HTTP Error 400. The size of the request headers is too long. This usually means that you have one or more cookies that have grown too big.

Why am I getting 400 Bad Request request header or cookie too large?

The "Request header too large" message is thrown with an HTTP error code 400. This error occurs if the size of the request header has grown so large that it exceeds the maximum-allowed size.


2 Answers

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

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.

This is bound to happen much more frequently to developers than end users as developers are logging in to the Azure portal with their corporate account, maybe also with a B2C admin account and then testing out their B2C-powered app with multiple logins.

In the long term, the answer will be to allow Azure AD B2C customers to specify their own custom domain. This gives the application's B2C cookies isolation from everything else in login.microsoftonline.com. As of 2019-06-23, this feature is still under development. You can support this feature and keep track of its progress by voting for it in the Azure AD B2C feedback forum: Customer-owned domains

However, in the interim, there are two things you can explore:

  1. Clear your cookies. This will definitely work every time, it's just cumbersome, especially if presented to your end users.

  2. Limit the amount of claims you include in your token. The more attributes you include in your policy, you'll end up with longer http requests which give you less margin for cookies from other Microsoft properties

Note: This is the same question as: http 400: size of header request is too long when signing in user using Multifactor authentication

2018-11 UPDATE:

Azure AD B2C allows you to use b2clogin.com instead of login.microsoftonline.com which will reduce your substantially reduce your exposure to this issue as you'll no longer share cookies with other Microsoft services.

like image 171
Saca Avatar answered Sep 25 '22 13:09

Saca


If you are encountering "HTTP Error 400 Bad Request - Request Too Long" for your azure account, you may also want to check whether the URL has been updated by microsoft.

In my case, I wanted to check on my Azure subscriptions. I used to go to this URL: https://account.azure.com/Subscriptions

But very recently it started giving me the "Bad Request Headers Too long" issue. I checked the URL and found out that it this is now the correct place to access my subscriptions: https://account.windowsazure.com/Subscriptions

like image 38
Phileo99 Avatar answered Sep 22 '22 13:09

Phileo99