Posts

Showing posts from 2017

Content Sharing using Google Drive ASP.NET MVC

Image
Hi Guys, I made a small content sharing portal using Google Drive and ASP.NET MVC Hope you like it. Things you must do before starting,  1) Register as a developer in google - https://developers.google.com/ 2) Create API Key and Client AUTH ID - https://developers.google.com/drive/v3/web/enable-sdk 3) Upload content to your google drive and grant public access 4) Create an ASP.NET MVC web application using Visual Studio 5) Create Page to Select and Save the ID of the uploaded content -  Store.cshtml @model BE.Video  <script type="text/javascript" src="https://apis.google.com/js/api.js?onload=onApiLoad"></script> <script>     $(document).ready(function () {         $("#gdriveSelect").click(function (event) {             event.preventDefault();             // do something         });     }); ...

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; }       ...

Secured Token Based WebAPI with custom authentication

Image
Hi Guys, I had a requirement to create Secured  Token Based WebAPI which can be consumed using mobile applications. And it had to check a custom authentication stored in database. Upon successful login an auth token would be returned subsequent requests must pass this auth token to get data. Reference : http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/ 1) Create a WebAPI Project as following 2) Modify the Startup.cs as following using Microsoft.Owin; using Microsoft.Owin.Security.OAuth; using Owin; using System; using System.Collections.Generic; 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 sta...