C#C
C#2y ago
Alex

✅ How to get Options from DI

I configured options for google authentication CliendId and ClientSecret.

builder.Services.ConfigureOptions<GoogleOptions>();


Here I want to get them from ServiceProvider but I don't know how. Should I create ServiceProvider var provider = builder.Services.BuildServiceProvider();?

builder.Services.AddAuthentication()
    .AddGoogle((options) =>
    {
        options.ClientId = "";
        options.ClientSecret = "";
    });
Was this page helpful?