This post is about token based authentication in ASP.NET Core. The general concept behind a token-based authentication system is simple. Allow users to enter their username and password in order to obtain a token which allows them to fetch a specific resource - without using their username and password. Once their token has been obtained, the user can offer the token - which offers access to a specific resource for a time period - to the remote site.
To use Token or JWT authentication, first you need to configure JWT Authentication middleware.
You’re done the configuration, now need to add the authentication middleware to application builder. You can do it in the Configure method.
Now you need a controller action method, which helps users to generate token.
Now you can protect the resources using [Authorize] attribute.
Here is the screenshot of POSTMAN get request without header.
Now you can generate the token using Token endpoint with the username and password, which will generate the token.
Next, you can request the values controller with Authorization header with the token received from Token endpoint, which will return the values.
If you’re using JQuery, you can use JQuery Ajax method with header like this.