private dynamic AuthorizeByExternalProvider(ProviderAndAccessToken model, ExternalProvider externalProvider) { IKernel kernel = Infrastructure.DependencyResolver.GetKernel(); IOauthProvider oauthProvider = kernel.Get <IOauthProvider>(externalProvider.ToString()); try { dynamic userData = oauthProvider.Authorize(model); userData.userName = userData.userData.userName.Replace(" ", ""); if (!userData.userName.ToString().Contains("@")) //google already adds @gmail.com to returned data so this should be optional. { userData.userName = userData.userName + "@" + externalProvider.ToString() + ".com"; } return(userData); } catch (Exception ex) { HttpContent contentPost = new StringContent("Facebook : " + ex.Message, Encoding.UTF8, "application/text"); var msg = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = contentPost }; throw new HttpResponseException(msg); } }