Question How to secure API?

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
94
Programming Experience
Beginner
I know we have an authorization attribute.

C#:
  [HttpGet("{id}")]
        [Authorize]
        public IActionResult Get(int id)

In the startup.cs

C#:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options => Configuration.Bind("JwtSettings", options))
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options => Configuration.Bind("CookieSettings", options));

After I run the API, it returns a 404 for me.

1) How to I make myself authorise to access the API?
2) Is there any other way also from which we can secure the API?
 

Latest posts

Back
Top Bottom