Posts

Showing posts from August, 2017

Self Hosted Microservice using OWIN, WebApi to authenticate users

Image
Hi Guys, This time I created Self Hosted Microservice using OWIN, WebApi to authenticate users, this service will store the authentication token on a file and subsequent requests are compared against the stored token. Hope you like it. 1) Create a console application as following 2) Install following packages using Nuget  Microsoft.AspNet.WebApi.OwinSelfHost Microsoft.Owin Microsoft.AspNet.Cors 3) Startup.cs  using Microsoft.Owin; using Microsoft.Owin.Security.OAuth; using Owin; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using System.Web.Http; namespace SelfHosted.MicroService {     public class Startup     {         // This code configures Web API. The Startup class is specified as a type         // parameter in the WebApp.Start method.       ...

Consuming a secured JWT webapi using ionic, angular 2

Image
I had a requirement to create an app which consumes a secured JWT webapi using ionic and angular 2. This is how I did it. Hope you like. Reference :  http://bitoftech.net/2015/02/16/implement-oauth-json-web-tokens-authentication-in-asp-net-web-api-and-identity-2/ 1) Open Startup.cs and paste the following code using Microsoft.Owin; using Microsoft.Owin.Security; using Microsoft.Owin.Security.DataHandler.Encoder; using Microsoft.Owin.Security.Jwt; using Microsoft.Owin.Security.OAuth; using Owin; using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Web; using System.Web.Http; [assembly: OwinStartup(typeof(SecuredWebAPI.Startup))] namespace SecuredWebAPI {     public class Startup     {         public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }         public static string PublicClientId { get; private set; }       ...