9

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.

lukkea
  • 3,606
  • 2
  • 37
  • 51
  • There are several ways to add Authentication to an existing project. For example, you could use filters, possibly combined with attributes, either built-in ones or custom ones. You can also use a DelegatingHandler, although that is probably not a good idea. – Bart van Nierop Oct 03 '14 at 12:53

1 Answers1

14

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.

Taiseer Joudeh
  • 8,953
  • 1
  • 41
  • 45