#ASP.NET Authentication
- Execution test Url --> https://localhost:44340/api/webapi
- Token generation url --> https://localhost:44340/token
- Install necessary Nugets
- Create the necessary tables and stored procedures
- [Authorize] attribute should be added to controller
- Add authentication configuration in the startup.cs
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); - Json format for the response
// WebAPI when dealing with JSON & JavaScript!
// Setup json serialization to serialize classes to camel (std. Json format)
var formatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
formatter.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); - Implementation authentication in start.auth.cs
- Implementation authentication provider in AppOAuthProvider
- Microsoft.Owin.Security.OAuth
- Microsoft.Owin.Cors
- Microsoft.AspNet.WebApi.Core
- Microsoft.AspNet.WebApi.Owin
- Microsoft.Owin.Security.Cookies
- Microsoft.AspNet.Identity.Core
- Microsoft.AspNet.Identity.Owin
- Microsoft.Owin.Host.SystemWeb
- https://www.c-sharpcorner.com/article/asp-net-mvc-oauth-2-0-rest-web-api-authorization-using-database-first-approach/
- https://docs.microsoft.com/en-us/previous-versions/aspnet/dn308223(v=vs.113)?redirectedfrom=MSDN
- Get Authorization code using the client credentials
- Parse the result and get access token
- Send the access token as an authourization header
- Newtonsoft.Json

