Error 400: redirect_uri_mismatch .net 7.0 google oauth 2.0

18 Views Asked by At
services.AddAuthentication().AddGoogle(googleOptions =>
{
    googleOptions.ClientId = configuration["Authentication:Google:ClientId"];
    googleOptions.ClientSecret = configuration["Authentication:Google:ClientSecret"];
    googleOptions.CallbackPath = "/signin-google/";
});

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
    {
        options.LoginPath = "/Auth/Login";
        options.Cookie.Name = "AshProgHelpCookie";
    });     

services.AddIdentity<IdentityUser, IdentityRole>(options =>
{
    // Configure password requirements
    options.Password.RequiredUniqueChars = 0;
    options.Password.RequireUppercase = false;
    options.Password.RequireLowercase = false;
    options.Password.RequiredLength = 6;
    options.Password.RequireNonAlphanumeric = false;
})
.AddEntityFrameworkStores<DataContext>()
.AddDefaultTokenProviders();

/*services.AddAuthorization(options =>
{
    options.FallbackPolicy = new AuthorizationPolicyBuilder()
        .RequireAuthenticatedUser()
        .Build();
});*/

services.AddScoped<IAuthService, AuthService>();
services.AddScoped<IProfileService, ProfileService>();

services.AddTransient<IEmailSender, EmailSender>();

services.AddControllersWithViews();
builder.Services.RegisterCoreConfiguration(builder.Configuration);
builder.Services.RegisterCoreDependencies();

upper program.cs , i used microsoft documentation but it return me this:enter image description here

I think it need to add javascript code for user get info and it redirect that user is authorized or create a controller.

0

There are 0 best solutions below