Using the Microsoft Dynamics CRM Online Web API from your ASP.Net MVC website
The MS Dynamics Web API has a lot of promise, allowing users to authenticate using OAuth2 then granting your application access to their CRM data. Unfortunately, the documentation provided by Microsoft is misleading at best.
After bashing my head against the wall for about ten hours, I got a response back from an MS developer with the following working solution, which I’ve padded-out and am sharing here to hopefully save somebody else the headache.
Here’s the working code sample, just drop in as a standard ActionResult in your MVC project – no other code is required/involved.