Validating JWT
From the figure, JSON web token sample, we achieved the generation of JSON Web Token and returned it as a response. Now, when any client (web, mobile, or desktop) calls the web API endpoint with the preceding generated token, we need to validate if this valid JWT is generated by our application.
If it validates successfully, then allow it to access the requested resource, that is, the user is authenticated now. If we don't validate it, then we are bound to get an unauthorized response.
Since this will be the first step when the API request reaches the HTTP pipeline, we need to add validation functionality in the Configure method of the Startup class using the UseJwtBearerAuthentication middleware.
Add the following piece of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access