I just created new Web API project (using MVC) in visual studio 2015 and for the testing purpose, I ran that project but ended up below error.
After running the project,
I got the answer here.
https://stackoverflow.com/a/29405794/8107314
And it was very useful to fix my error my error
I just came across the same problem and found the solution:
You need to register the OAuth Token Generator and OAuth Token Consumer things before WebAPI is registered.
Kind of makes sense if you think of this as a pipeline, where Authentication/Authorization should come before any request handling by the controllers.
TL;DR: Change
appBuilder.UseWebApi(config);
this.ConfigureOAuthTokenGenerator(appBuilder);
this.ConfigureOAuthConsumer(appBuilder);
To
this.ConfigureOAuthTokenGenerator(appBuilder);
this.ConfigureOAuthConsumer(appBuilder);
appBuilder.UseWebApi(config);