-
Book Overview & Buying
-
Table Of Contents
ASP.NET Web API Security Essentials
By :
To send an authenticated request to ValuesController, we need to pass an access token in the Authorization header. How do we get this access token? To get this access token, we need to log in the application.
Let's first register a user by posting an instance of the user to the Web API Register action method in the Account controller, as follows:

Fig 12 – POSTing an instance of User to Web API
Now, we have a registered user with the username [email protected] and password Password@1. Let's send form with URL encoded data in the request body to the token endpoint, as follows:
{
"grant_type": "password",
"username": "[email protected]",
"Password": "Password@1"
}Let's send this instance to the Token endpoint using Fiddler as given in the following:

Fig 13 – POSTing an instance of User with the grant type to Token endpoint
We will receive a response with the token in the Set-Cookie header, as shown in the following screenshot:

Fig 14 – Response with Token in the Set-Cookie header...
Change the font size
Change margin width
Change background colour