@@ -52,13 +52,13 @@ public static IServiceCollection AddSqlAppTokenCache(this IServiceCollection ser
52
52
{
53
53
// Uncomment the following lines to create the database. In production scenarios, the database
54
54
// will most probably be already present.
55
- /*
55
+ /*
56
56
var tokenCacheDbContextBuilder = new DbContextOptionsBuilder<TokenCacheDbContext>();
57
57
tokenCacheDbContextBuilder.UseSqlServer(sqlTokenCacheOptions.SqlConnectionString);
58
58
59
59
var tokenCacheDbContextForCreation = new TokenCacheDbContext(tokenCacheDbContextBuilder.Options);
60
60
tokenCacheDbContextForCreation.Database.EnsureCreated();
61
- */
61
+ */
62
62
services . AddDataProtection ( ) ;
63
63
64
64
services . AddDbContext < TokenCacheDbContext > ( options =>
@@ -84,13 +84,18 @@ public static IServiceCollection AddSqlPerUserTokenCache(this IServiceCollection
84
84
{
85
85
// Uncomment the following lines to create the database. In production scenarios, the database
86
86
// will most probably be already present.
87
- //var tokenCacheDbContextBuilder = new DbContextOptionsBuilder<TokenCacheDbContext>();
88
- //tokenCacheDbContextBuilder.UseSqlServer(sqlTokenCacheOptions.SqlConnectionString);
87
+ /*
88
+ var tokenCacheDbContextBuilder = new DbContextOptionsBuilder<TokenCacheDbContext>();
89
+ tokenCacheDbContextBuilder.UseSqlServer(sqlTokenCacheOptions.SqlConnectionString);
89
90
90
- //var tokenCacheDbContextForCreation = new TokenCacheDbContext(tokenCacheDbContextBuilder.Options);
91
- //tokenCacheDbContextForCreation.Database.EnsureCreated();
91
+ var tokenCacheDbContextForCreation = new TokenCacheDbContext(tokenCacheDbContextBuilder.Options);
92
+ tokenCacheDbContextForCreation.Database.EnsureCreated();
93
+ */
92
94
93
- services . AddDataProtection ( ) ;
95
+ // To share protected payloads among apps, configure SetApplicationName in each app with the same value.
96
+ // https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-2.2#setapplicationname
97
+ services . AddDataProtection ( )
98
+ . SetApplicationName ( "WebApp_Tutorial" ) ;
94
99
95
100
services . AddDbContext < TokenCacheDbContext > ( options =>
96
101
options . UseSqlServer ( sqlTokenCacheOptions . SqlConnectionString ) ) ;
0 commit comments