0

Project is .NET 3.1 and we are sending requests to Ocelot.

However, we are using an email with special character, such as: sömêthìng@example.com

So, when user authenticates, the bearer token will have this email because it's also the user's username.

However, when sending the request to Ocelot, I'm having the following exception: System.Net.Http.HttpRequestException: Request headers must contain only ASCII characters.

enter image description here

However, I read that this was treated in .NET 2.1 (or 2.2). Is this still an issue with 3.1? I tried to converted to base64, but the same exception occurred, like this:

enter image description here

Thanks!

André Miranda
  • 6,420
  • 20
  • 70
  • 94
  • I am not experienced enough with http auth, but as for me, requests come with `Authorization` header and `Bearer` authentication schema instead of containing token hold email, right? May be this is XY problem? Looks very weird at least. – Ryan Nov 17 '22 at 18:38
  • Could you please share your `code snippet` as well? Did you try using `HttpUtility.HtmlEncode(auth.header)`. – Md Farid Uddin Kiron Nov 18 '22 at 02:33
  • In addtion, you even can use `Encoding.ASCII.GetBytes(authHeader.Parameter);` – Md Farid Uddin Kiron Nov 18 '22 at 02:41
  • Indeed, I ended up covnerting the email to base64 before adding it to the bearer token, which was my issue – André Miranda Nov 18 '22 at 15:22

0 Answers0