public static BaseOauth2Service GetService(string appName, string id, string absoluteUri) { switch (id.ToLower()) { case "google": return(new GoogleService(Oauth2LoginFactory.CreateClient <GoogleClient>(appName, "Google"), absoluteUri)); break; case "facebook": return(new FacebookService(Oauth2LoginFactory.CreateClient <FacebookClient>(appName, "Facebook"), absoluteUri)); break; //case "windowslive": // return new WindowsLiveService(Oauth2LoginFactory.CreateClient<WindowsLiveClient>(appName,"WindowsLive")); // break; case "paypal": return(new PayPalService(Oauth2LoginFactory.CreateClient <PayPalClient>(appName, "PayPal"), absoluteUri)); break; case "twitter": return(new TwitterService(Oauth2LoginFactory.CreateClient <TwitterClient>(appName, "Twitter"))); break; default: return(null); } }
// TODO: This looks horrible, refactor using generics public static BaseOauth2Service GetService(string id) { switch (id.ToLower()) { case "google": return(new GoogleService(Oauth2LoginFactory.CreateClient <GoogleClient>("Google"))); break; case "facebook": return(new FacebookService(Oauth2LoginFactory.CreateClient <FacebookClient>("Facebook"))); break; // Need to transition WindowLive to new base class //case "windowslive": // return new WindowsLiveService(Oauth2LoginFactory.CreateClient<WindowsLiveClient>("WindowsLive")); // break; case "paypal": return(new PayPalService(Oauth2LoginFactory.CreateClient <PayPalClient>("PayPal"))); break; case "twitter": return(new TwitterService(Oauth2LoginFactory.CreateClient <TwitterClient>("Twitter"))); break; default: return(null); } }
public ActionResult Login(string id = "", string bindpage = "") { string url = ""; AbstractClientProvider client = null; try { switch (id.ToLower()) { case "google": client = Oauth2LoginFactory.CreateClient <GoogleClinet>("Google"); break; case "facebook": client = Oauth2LoginFactory.CreateClient <FacebookClient>("Facebook"); break; case "windowslive": client = Oauth2LoginFactory.CreateClient <WindowsLiveClient>("WindowsLive"); break; case "paypal": client = Oauth2LoginFactory.CreateClient <PayPalClient>("PayPal"); break; default: return(RedirectToAction("index")); } if (client != null) { if (bindpage.Equals("1")) { client.CallBackUrl += "?bindpage=1"; } _context = Oauth2LoginContext.Create(client); url = _context.BeginAuth(); } } catch (Exception) { throw; } return(Json(new { Url = url })); #region old // private static MultiOAuthContext _context; //string url = ""; //IClientProvider client; //try //{ // switch (id.ToLower()) // { // case "google": // client = MultiOAuthFactroy.CreateClient<GoogleClinet>("Google"); // break; // case "facebook": // client = MultiOAuthFactroy.CreateClient<FacebookClient>("Facebook"); // break; // case "windowslive": // client = MultiOAuthFactroy.CreateClient<WindowsLiveClient>("WindowsLive"); // break; // default: // return RedirectToAction("index"); // } // if (client != null) // { // if (bindpage.Equals("1")) // client.CallBackUrl += "?bindpage=1"; // _context = MultiOAuthContext.Create(client); // url = _context.BeginAuth(); // } //} //catch (Exception) //{ // throw; //} //return Json(new { Url = url }); #endregion }