Skip to content

Commit 94b9fd0

Browse files
author
Tiago Brenck
committed
AddHttpContextAccessor
1 parent 3267c77 commit 94b9fd0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

4-WebApp-your-API/TodoListService/Startup.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ public void ConfigureServices(IServiceCollection services)
5353
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
5454
//JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
5555

56-
services.AddProtectedWebApi(Configuration)
57-
.AddInMemoryTokenCaches();
56+
services.AddHttpContextAccessor();
57+
58+
services.AddProtectedWebApi(Configuration);
5859

5960
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
6061
}

Microsoft.Identity.Web/WebApiServiceCollectionExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public static IServiceCollection AddProtectedWebApi(
4444
services.AddAuthentication(AzureADDefaults.JwtBearerAuthenticationScheme)
4545
.AddAzureADBearer(options => configuration.Bind(configSectionName, options));
4646

47-
// Add session if you are planning to use session based token cache , .AddSessionTokenCaches()
48-
// services.AddSession(); // Commented as we cannot force session on someone who wants to use an alternative token cache provider.
49-
5047
// Change the authentication configuration to accommodate the Microsoft identity platform endpoint (v2.0).
5148
services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options =>
5249
{

0 commit comments

Comments
 (0)