ASP.NET MVC: REST Web API Basic Authorization using Nuget Library
When a REST Web API is created to share data across multiple devices e.g. mobile devices, desktop applications or any website, then the authorization of REST Web API becomes a vital aspect in order to protect data sensitivity from any outside breaches. I have recently created my own small REST Web API Authorization library Asmak9.AuthorizeRESTWebApiAK which is compatible with any ASP.NET and .NET Console Application project.
Today, I shall be demonstrating integration of Asmak9.AuthorizeRESTWebApiAK .NET library with ASP.NET REST Web API platform.
1) Create new Web API project and name it "RESTWebAuthorization".
2) Open "Tools\Nuget Package Manage\Manage Nuget Packages for Solution...".
3) Install Asmak9.AuthorizeRESTWebApiAK NuGet Package i.e.
4) Open "Global.asax.cs" file and add following lines of code i.e.
The above code will register REST Web API authorization handler with the OWIN security layer of your REST Web API project base on your provided API key header name, API key value, authorize username and authorize password. If you have purchased the license key of this library then you can provide your license key in the last parameter i.e.
5) Lets, test out REST Web API in action using REST Web API client. I am using fire fox plugin i.e. "RESTED". At, first, I simply try to hit the REST Web API without any authorization details and I will get following response i.e.
6) Now, I will provide the authorization and hit the REST Web API and will get following response i.e.
Today, I shall be demonstrating integration of Asmak9.AuthorizeRESTWebApiAK .NET library with ASP.NET REST Web API platform.
Prerequisites:
Following are some prerequisites before you proceed any further in this tutorial:- Install Asmak9.AuthorizeRESTWebApiAK NuGet Package.
- Knowledge of REST Web API.
- Knowledge of ASP.NET MVC5.
- Knowledge of C# Programming.
Download Now!
Let's begin now.1) Create new Web API project and name it "RESTWebAuthorization".
2) Open "Tools\Nuget Package Manage\Manage Nuget Packages for Solution...".
3) Install Asmak9.AuthorizeRESTWebApiAK NuGet Package i.e.
4) Open "Global.asax.cs" file and add following lines of code i.e.
RESTWebAPIAuthHeaderHandler obj = new RESTWebAPIAuthHeaderHandler(ApiInfo.API_KEY_HEADER, ApiInfo.API_KEY_VALUE, ApiInfo.USERNAME_VALUE, ApiInfo.PASSWORD_VALUE); // API authorization registration. GlobalConfiguration.Configuration.MessageHandlers.Add(obj);
The above code will register REST Web API authorization handler with the OWIN security layer of your REST Web API project base on your provided API key header name, API key value, authorize username and authorize password. If you have purchased the license key of this library then you can provide your license key in the last parameter i.e.
RESTWebAPIAuthHeaderHandler obj = new RESTWebAPIAuthHeaderHandler(ApiInfo.API_KEY_HEADER, ApiInfo.API_KEY_VALUE, ApiInfo.USERNAME_VALUE, ApiInfo.PASSWORD_VALUE, "My_LICENSE_KEY"); // API authorization registration. GlobalConfiguration.Configuration.MessageHandlers.Add(obj);
5) Lets, test out REST Web API in action using REST Web API client. I am using fire fox plugin i.e. "RESTED". At, first, I simply try to hit the REST Web API without any authorization details and I will get following response i.e.
6) Now, I will provide the authorization and hit the REST Web API and will get following response i.e.
Thanks For sharing valuable Information....
ReplyDeleteMovie box is excellent application for them who love to enjoy
their time with movies and TV series.There was a time when watching
and downloading movies.
movies box apk
moviebox download android