This project has moved. For the latest updates, please go here.

Implementing OAuth for MVC Applications

Jan 8, 2014 at 3:35 AM
Edited Jan 8, 2014 at 3:37 AM
I have added the LinqToTwitter reference v2.1.11 to my VS 2013 .net 4.5 MVC project. And read the following:

I am not able to see the same methods for the MvcAuthorizer as in the above documentation. Best I can implement is
    public async Task<ActionResult> BeginAsync()
        //var auth = new MvcSignInAuthorizer
        var auth = new LinqToTwitter.MvcAuthorizer
            Credentials = new SessionStateCredentials
                ConsumerKey = ConfigurationManager.AppSettings["consumerKey"],
                ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"]
        string twitterCallbackUrl = Request.Url.ToString().Replace("Begin", "Complete");
        return await auth.BeginAuthorization(new Uri(twitterCallbackUrl));
Please note BeginAuthorization and not BeginAuthorizationAsync.

Error I am seeing is "Cannot await 'System.Web.Mvc.ActionResult'" on line

return await auth.BeginAuthorization(new Uri(twitterCallbackUrl));
Jan 8, 2014 at 3:51 AM

There's a LinqToTwitterMvcDemo project in the downloadable source code that has an example for 2.1.11. The documentation is for v3.0.

Marked as answer by CodeMonkeyMakeApp on 1/8/2014 at 2:42 PM
Jan 8, 2014 at 1:56 PM
You rock Joe! If I have anything to contribute to the project I'll forward to you.
Jan 8, 2014 at 3:04 PM
Edited Jan 8, 2014 at 10:42 PM
Jan 8, 2014 at 3:12 PM
Edited Jan 8, 2014 at 10:42 PM