I was going through Microsoft's documentation on how to add OAuth to a web application (I'm using .NET core) but then I got to this point:
Add the Google service to Startup.ConfigureServices.
I don't have a Startup
class, not even a file. While searching for how to deal with it, I found this answer, which drove me to found out that this is a OWIN file (whatever that means) and that I should just right click and add it and everything would be fine. I then proceeded to add the owin packages (this is even redundant, I know):
<PackageReference Include="Microsoft.Owin" Version="4.2.0" />
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" Version="4.2.0" />
<PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.2.0" />
Tried then to reload the project, reopen Visual Studio (using Visual Studio 2022 RC) but this class won't show up:
I just need to add OAuth to my application... Do I really need to do this? If so, what can I do? I just need a functional ConfigureServices
method like the documentation shows:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDefaultIdentity<IdentityUser>(options =>
options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddRazorPages();
services.AddAuthentication()
.AddGoogle(options =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
options.ClientId = googleAuthNSection["ClientId"];
options.ClientSecret = googleAuthNSection["ClientSecret"];
});
}
This is how my project is right now: