Upgrading TokenController

Now, we're all set to generate, store, and send the refresh tokens to the clients, and also receive them back. All these tasks will be done within our TokenController, which we need to upgrade in a number of ways.

The first thing to do is to handle the refresh_token grant-type by upgrading the existing Auth() action method:

[...]switch (model.grant_type){    case "password":        return await GetToken(model);                 case "refresh_token":        return await RefreshToken(model);    default:        // not supported - return a HTTP 401 (Unauthorized)        return new UnauthorizedResult();}[...]

Right after that, we need to implement the RefreshToken() private method we're referencing to:

[...]private async Task<IActionResult> RefreshToken(TokenRequestViewModel ...

Get ASP.NET Core 2 and Angular 5 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.