This is an example of implementation of JSON Web Token (JWT) authentification for ASP Core Web API. It is based on SimpleTokenProvider. Some of ideas were taken from openiddict-samples. It has the similar implementation as SimpleTokenProvider but as service with a controller. In that repo you may get ideas how to implement it in your own project.
I wanted to create self made implementaion of JWT authentification as in SimpleTokenProvider but not using midleware.
- Clone repo
- Add user secrets:
{
"TokenKey": "MySuperSecret_!123",
"TokenIssuer": "issuer",
"TokenAudience": "audience"
}
-
Generate database using migrations
-
Create user using ASP Identity
-
Send POST request to that URL: http://localhost:49940/api/auth
HEADER:
Content-Type: application/x-www-form-urlencoded
BODY:
username: YourUserName
password: YourPassword