Add Authentication to ASP.NET WebApi 2.2

lukkea picture lukkea · Oct 3, 2014 · Viewed 9.5k times · Source

I have created a WebApi 2.2 project (from an Empty New ASP.NET Project) to prove some implementation concepts and I now want to add Authentication to it.

I notice that the only way to add Authentication on a new WebApi app is to use one of the (VS 2013, in my case) Templates.

Is there a sure-fire way of adding Authentication to an already existing WebApi 2.2 app?

I will only want to use bearer tokens, if that makes a difference to any answers I may receive.

Answer

Taiseer Joudeh picture Taiseer Joudeh · Oct 4, 2014

Yes you can add the bearer authentication from scratch, I'm not big fan of the VS 2013 templates because they mix between cookies and tokens authentication. You can check my detailed blog post on how to add bearer tokens only to new or existing Web API project. Let me know if you need further help.