public OAuthOptions() { Events = new OAuthEvents(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDatabaseErrorPage(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 try { using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>() .CreateScope()) { serviceScope.ServiceProvider.GetService<ApplicationDbContext>() .Database.Migrate(); } } catch (Exception) { } } app.UseRequestLocalization(new RequestLocalizationOptions() { SupportedCultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("nl-NL") }, SupportedUICultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("nl-NL") }, }, new RequestCulture(new CultureInfo("nl-NL"))); app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseStaticFiles(); app.UseIdentity(); var onRemoteError = new OAuthEvents() { OnRemoteError = ctx => { ctx.Response.Redirect("/Account/ExternalLoginCallback?RemoteError=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message)); ctx.HandleResponse(); return Task.FromResult(0); } }; // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 if (Configuration["Authentication:Google:ClientId"] != null) { app.UseFacebookAuthentication(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; options.DisplayName = "facebook"; options.Events = onRemoteError; }); app.UseGoogleAuthentication(options => { options.ClientId = Configuration["Authentication:Google:ClientId"]; options.ClientSecret = Configuration["Authentication:Google:ClientSecret"]; options.DisplayName = "google plus"; options.Events = onRemoteError; }); } app.UseCacheWrite(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(LogLevel.None); app.UseDatabaseErrorPage(); app.UseDeveloperExceptionPage(); app.UseRequestLocalization(new RequestLocalizationOptions() { SupportedCultures = new List<CultureInfo> { new CultureInfo("en-US") }, SupportedUICultures = new List<CultureInfo> { new CultureInfo("en-US") }, }, new RequestCulture(new CultureInfo("nl-NL"))); app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseStaticFiles(); app.UseIdentity(); app.EnsureSampleData().Wait(); var onRemoteError = new OAuthEvents() { OnRemoteError = ctx => { ctx.Response.Redirect("/Account/ExternalLoginCallback?RemoteError=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message)); ctx.HandleResponse(); return Task.FromResult(0); } }; // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 if (_startup.Configuration["Authentication:Google:ClientId"] != null) { app.UseFacebookAuthentication(options => { options.AppId = _startup.Configuration["Authentication:Facebook:AppId"]; options.AppSecret = _startup.Configuration["Authentication:Facebook:AppSecret"]; options.DisplayName = "facebook"; options.Events = onRemoteError; }); app.UseGoogleAuthentication(options => { options.ClientId = _startup.Configuration["Authentication:Google:ClientId"]; options.ClientSecret = _startup.Configuration["Authentication:Google:ClientSecret"]; options.DisplayName = "google plus"; options.Events = onRemoteError; }); } app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }