Step 6 – Adding the ProfileService class

While we explored all this, I left out one part that I want to explain now. If you see the body of the request while we fetch the access token, it is something like:

grant_type=password&scope=FlixOneStore.ReadAccess&client_id=htmlClient&client_secret=secretpassword&username=taditdash@gmail.com&password=12345

Focus on the username and password parameters. They are here for a reason. While generating the token, these are getting validated and yes, we are validating with the database directly. Let's see how.

IdentityServer4 provides two interfaces for this purpose, named IProfileService and IResourceOwnerPasswordValidator.

The following is a ResourceOwnerPasswordValidator class implementing the interface. ...

Get Building RESTful Web Services with .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.