Skip to content

Commit 4f9a9bc

Browse files
authored
Merge pull request #97 from Azure-Samples/jmprieur/syncMicrosoftIdentityWebFromWebAppTutorial
Fixing the config for the Web API
2 parents 0fd10f2 + a25100f commit 4f9a9bc

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

2. Web API now calls Microsoft Graph/TodoListService/Startup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ public void ConfigureServices(IServiceCollection services)
3333
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3434
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
3535
{
36-
app.UseSession();
37-
3836
if (env.IsDevelopment())
3937
{
4038
// Since IdentityModel version 5.2.1 (or since Microsoft.AspNetCore.Authentication.JwtBearer version 2.2.0),

Microsoft.Identity.Web/WebApiServiceCollectionExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ public static IServiceCollection AddProtectedWebApi(
3838
this IServiceCollection services,
3939
IConfiguration configuration,
4040
X509Certificate2 tokenDecryptionCertificate = null,
41-
string configSectionName = "AzureAD",
41+
string configSectionName = "AzureAd",
4242
bool subscribeToJwtBearerMiddlewareDiagnosticsEvents = false)
4343
{
4444
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
4545
.AddAzureADBearer(options => configuration.Bind(configSectionName, options));
46+
services.Configure<AzureADOptions>(options => configuration.Bind(configSectionName, options));
4647

4748
services.AddHttpContextAccessor();
4849

4950
// Change the authentication configuration to accommodate the Microsoft identity platform endpoint (v2.0).
5051
services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options =>
5152
{
52-
// Reinitialize the options as this has changed to JwtBearerOptions to pick configuration values for attributes unique to JwtBearerOptions
53-
configuration.Bind(configSectionName, options);
54-
5553
// This is an Microsoft identity platform Web API
5654
options.Authority += "/v2.0";
5755

0 commit comments

Comments
 (0)