using Microsoft.AspNet.Builder; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Security; using Microsoft.AspNet.Security.Cookies; using Microsoft.AspNet.Security.Facebook; using Microsoft.AspNet.Security.Google; using Microsoft.AspNet.Security.Twitter; namespace CookieSample { public class Startup { public void Configure(IBuilder app) { app.UseErrorPage(); app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions() { LoginPath = new PathString("/login"), }); app.UseFacebookAuthentication(new FacebookAuthenticationOptions() { AppId = "569522623154478", AppSecret = "a124463c4719c94b4228d9a240e5dc1a", }); app.UseGoogleAuthentication(new GoogleAuthenticationOptions() { ClientId = "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com", ClientSecret = "n2Q-GEw9RQjzcRbU3qhfTj8f", }); app.UseTwitterAuthentication(new TwitterAuthenticationOptions() { ConsumerKey = "6XaCTaLbMqfj6ww3zvZ5g", ConsumerSecret = "Il2eFzGIrYhz6BWjYhVXBPQSfZuS4xoHpSSyD9PI", }); // Choose an authentication type app.Map("/login", signoutApp => { signoutApp.Run(async context => { string authType = context.Request.Query["authtype"]; if (!string.IsNullOrEmpty(authType)) { // By default the client will be redirect back to the URL that issued the challenge (/login?authtype=foo), // send them to the home page instead (/). context.Response.Challenge(new AuthenticationProperties() { RedirectUri = "/" }, authType); return; } context.Response.ContentType = "text/html"; await context.Response.WriteAsync("
"); await context.Response.WriteAsync("Choose an authentication type: