From the course: Building and Securing RESTful APIs in ASP.NET Core

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a UserInfo route

Create a UserInfo route - ASP.NET Core Tutorial

From the course: Building and Securing RESTful APIs in ASP.NET Core

Start my 1-month free trial

Create a UserInfo route

- [Narrator] Now that the client can get an access token from the token route, let's add a new end point that will return the profile of the current user. This is a common pattern for single page and mobile apps and it's something that OpenID Connect calls a user info endpoint. Another way to pass the users profile down to the app is by using the OpenID Connect ID token, but that's beyond the scope of this course. I'm gonna create a new controller here called UserinfoController. And it'll inherit from ControllerBase, as we always do. We'll require authorization or authentication at all times for this controller. You have to have a valid access token to call it. And we'll make it an ApiController. And let's say that the Route is just gonna be /userinfo. So we'll do /controller. Okay, this controller is going to need to talk to the user service so let's do private readonly IuserService _userService_ And then in the constructor we'll grab an IUserService. Let's create an action method…

Contents