Bearer token is not used by Swagger for endpoints with [authorize], but used for [AllowAnonymous]

Hey!

Yesterday while working on a project for university I encountered a strange bug, which can be seen in the screens below:

  • When an endpoint is marked with the [Authorize] attribute, even if a Bearer Token is specified in Swagger, this Token will not be used in the execution of the request.
  • If we use the [AllowAnonymous] attribute instead of [Authorize], the Bearer Token will be sent in the request.
The described behaviour can be seen in the screenshots. Does anyone know what might be generating it? And how can I fix it?
image.png
image.png
image.png
image.png
image.png
Was this page helpful?