© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
5 replies
BekirK

✅ Authorize() Attribute is not working (SOLVED)

Hello everyone, I implemented Jwt in .net 6 for a project. I have shared my JwtHelper and program class. When I add [Authorize()] attribute for getall request in Controller, it doesn't work, I keep getting unauthorize error. I login and accessToken is created then I use it for getall method in Postman like “Bearer xxxxxxxx” but again it returns unauthorized.
I've been trying for days and couldn't find the error. Can you help me please

You can also access the repo: https://github.com/BekirK-C/Simpra_Final_Project

[HttpGet("getall")]
    [Authorize()]
    public IActionResult GetAll()
    {
        var result = _productManager.GetAll();
        if (result.Success)
        {
            return Ok(result);
        }
        return BadRequest(result.Message);
    }
[HttpGet("getall")]
    [Authorize()]
    public IActionResult GetAll()
    {
        var result = _productManager.GetAll();
        if (result.Success)
        {
            return Ok(result);
        }
        return BadRequest(result.Message);
    }
JwtHelper.png
program.cs.png
GitHub
GitHub - BekirK-C/Simpra_Final_Project
Contribute to BekirK-C/Simpra_Final_Project development by creating an account on GitHub.
GitHub - BekirK-C/Simpra_Final_Project
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Asp Net Core Authorize Attribute
C#CC# / help
4y ago
❔ Authorize attribute automatically triggering oauth scheme
C#CC# / help
4y ago
Url.Action not working [NOT SOLVED]
C#CC# / help
4y ago