Twitter Login not working

Nov 24, 2011 at 2:57 AM

Hello:

I have setup a new twitter application.  I associated it with my account.

But everytime I click thw Twitter button on the Sign In page, I get an ASP.NET exception from the LinqToTwitter assembly.  It's related to this, because another module that uses the same assembly (I am sharing it across both of the modules, due to versin conflicts).

Previously, I had the default application key and secret key in the settings -> Open Authentication area.  When I did this, I kept getting redirected to an endless loop.  After changing the Twitter app key and secret to my own, I now get this .net exception.

I must be missing something simple.

The remote server returned an error: (401) Unauthorized.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Source Error:

Line 146:            public void EndProcessRequest(IAsyncResult result) {
Line 147:                try {
Line 148:                    _httpAsyncHandler.EndProcessRequest(result);
Line 149:                }
Line 150:                finally {


Source File: ...\src\Orchard\Mvc\Routes\ShellRoute.cs    Line: 148

Stack Trace:

[WebException: The remote server returned an error: (401) Unauthorized.]
   LinqToTwitter.OAuthTwitter.WebResponseGet(HttpWebRequest webRequest) +229
   LinqToTwitter.OAuthTwitter.WebRequest(HttpMethod method, String url, String authHeader, String postData) +705
   LinqToTwitter.OAuthTwitter.OAuthWebRequest(HttpMethod method, String url, String postData, String callback) +1518
   LinqToTwitter.OAuthTwitter.AuthorizationLinkGet(String requestToken, String authorizeUrl, String callback, Boolean forceLogin) +46
   LinqToTwitter.WebAuthorizer.BeginAuthorization(Uri callback, Boolean forceLogin) +91
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825604
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825632
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in C:\code\eduncan911\trunk\orchard\src\Orchard\Mvc\Routes\ShellRoute.cs:148
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

 

 


Nov 24, 2011 at 3:31 AM

Well, after setting a "Callback" url, it now redirects back to the sign in page.  But new text is added at the top:

Account Association: Your new user account will be linked to {some hashed set of chars}.

I was getting this before with the default Twitter App key/secret keys, before I started using my own.

I do have the Settings option for allowing users to create new accounts in teh system, and I do have the Open Authentication option for allowing users to register. 

Everything else works such as Google, Wordpress, OpenID, and including Facebook after my app id and secret keys were used.

It's only this twitter portion...

Coordinator
Nov 29, 2011 at 11:08 PM

Wierd!! I have only seen this when twitter throws an unhandled exception.

I will investigate.

Could you use the dev branch please and let me know if this error is still occuring.

Cheers, Nick

Nov 30, 2011 at 12:56 AM

Thanks for the reply Nick!

I'm actually working from the developer branch (but not edited) dated Oct 3rd, 2011, which was the tagged release of 1.3.9:

http://orchard.codeplex.com/SourceControl/changeset/changes/8732e2734cd2

Are you saying you want me to try the latest?  I've been following just about every checkin since that revision above, and didn't notice anything that would affect this.

I did this because I am building to be hosted in Azure.  To be accurate, these tests were performed under IIS 7.5 if that matters (not Azure nor IIS Express).  If that matters.

Thanks!