Sitecore Social Connected Exception: "Application in args should not be null"

Sitecore Social Connected Exception: "Application in args should not be null"

You might run into this exception when trying to log in using one of the social connectors that is part of the Sitecore Social Connected module (Facebook, Twitter, LinkedIn, Google+)

ERROR Sitecore.Social: Application in args should not be null
Exception: Sitecore.Social.NetworkProviders.Exceptions.AuthException
Message: Exception of type 'Sitecore.Social.NetworkProviders.Exceptions.AuthException' was thrown.
Source: Sitecore.Social.NetworkProviders
   at Sitecore.Social.NetworkProviders.Exceptions.Analyzers.ArgsExceptionAnalyzer.Analyze(AuthArgs args)
   at Sitecore.Social.Client.Connector.SocialLogin.ProcessRequest(HttpContext httpContext)

I ran into this exception the other day and was a bit confused at it had been working fine.

It turns out a change had been made to our setup to always include the language as the first part in the URL - and if it was missing it would redirect to the correct URL including the language part.

When you click on one of the Social Connector buttons to log in, the module makes a POST request to /Social/TwitterConnector/Login (or the equivalent for the other connectors). These use standard MVC to generate a form which points to the Login method on the corresponding controller.

@using (Html.BeginForm("Login", null, new { area = "Social" }, FormMethod.Post, new { style = "display:inline" }))
{
  @Html.HiddenFor(model => model.Parameters)

  <input type="image" title='@Model.ToolTip' style="margin:0 1px" src="@Url.Content(Model.Icon)" />
}

The redirect logic that was setup was also redirecting POST requests, but redirected POST requests turn into GET and also no longer include the form parameters.

Conclusion

So what can we learn from all this?

Do not redirect POST requests. Please.