© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
8 replies
SirCypkowskyy

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]
[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]
[AllowAnonymous]
attribute instead of
[Authorize]
[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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Implementing auth0 with .NET Swagger bearer token authorize seems to be working, but not tables
C#CC# / help
2y ago
Scalar with Bearer Token
C#CC# / help
12mo ago
[AllowAnonymous] not working when request was handled by YARP
C#CC# / help
2y ago
❔ SingalR Hub Bearer Token Auth
C#CC# / help
3y ago