Skip to content

Commit d9c9a3d

Browse files
authored
Merge pull request #238 from Azure-Samples/jennyf/idweb2.10
update to 2.10
2 parents dcba094 + 5dcb983 commit d9c9a3d

File tree

8 files changed

+40
-117
lines changed

8 files changed

+40
-117
lines changed

1. Desktop app calls Web API/TodoListClient/MainWindow.xaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.Identity.Client;
5+
using Microsoft.Identity.Client.Desktop;
6+
using Microsoft.Identity.Client.Extensions.Msal;
57
using Newtonsoft.Json;
68
using System.Collections.Generic;
79
using System.Configuration;
@@ -62,12 +64,22 @@ private static string TodoListApiAddress
6264
public MainWindow()
6365
{
6466
InitializeComponent();
67+
68+
// Create the app
6569
_app = PublicClientApplicationBuilder.Create(ClientId)
6670
.WithAuthority(Authority)
6771
.WithRedirectUri("http://localhost") // needed only for the system browser
6872
.Build();
6973

70-
TokenCacheHelper.EnableSerialization(_app.UserTokenCache);
74+
// Add token cache serialization
75+
var storageProperties =
76+
new StorageCreationPropertiesBuilder(
77+
"ClientConsoleApp",
78+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
79+
.Build();
80+
var cacheHelper = MsalCacheHelper.CreateAsync(storageProperties).GetAwaiter().GetResult();
81+
cacheHelper.RegisterCache(_app.UserTokenCache);
82+
7183
GetTodoList();
7284
}
7385

1. Desktop app calls Web API/TodoListClient/TodoListClient.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net5-windows10.0.17763.0</TargetFramework>
5+
<TargetFramework>net472</TargetFramework>
66
<UseWPF>true</UseWPF>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Identity.Client" Version="4.38.0" />
11-
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
10+
<PackageReference Include="Microsoft.Identity.Client" Version="4.53.0" />
11+
<PackageReference Include="Microsoft.Identity.Client.Desktop" Version="4.53.0" />
12+
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.29.0" />
13+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<Reference Include="System.Configuration" />
1218
</ItemGroup>
1319

1420
<ItemGroup>

1. Desktop app calls Web API/TodoListClient/TokenCacheHelper.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

1. Desktop app calls Web API/TodoListService/TodoListService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Identity.Web" Version="2.8.0" />
10+
<PackageReference Include="Microsoft.Identity.Web" Version="2.10.0" />
1111
</ItemGroup>
1212
</Project>

2. Web API now calls Microsoft Graph/TodoListClient/MainWindow.xaml.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.Identity.Client;
5+
using Microsoft.Identity.Client.Extensions.Msal;
56
using Newtonsoft.Json;
67
using System.Collections.Generic;
78
using System.Configuration;
@@ -65,7 +66,15 @@ public MainWindow()
6566
.WithDefaultRedirectUri()
6667
.Build();
6768

68-
TokenCacheHelper.EnableSerialization(_app.UserTokenCache);
69+
// Add token cache serialization
70+
var storageProperties =
71+
new StorageCreationPropertiesBuilder(
72+
"ClientConsoleApp",
73+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
74+
.Build();
75+
var cacheHelper = MsalCacheHelper.CreateAsync(storageProperties).GetAwaiter().GetResult();
76+
cacheHelper.RegisterCache(_app.UserTokenCache);
77+
6978
GetTodoList();
7079
}
7180

2. Web API now calls Microsoft Graph/TodoListClient/TodoListClient.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
<SubType>Designer</SubType>
6565
</ApplicationDefinition>
6666
<Compile Include="TodoItem.cs" />
67-
<Compile Include="TokenCacheHelper.cs" />
6867
<Page Include="MainWindow.xaml">
6968
<Generator>MSBuild:Compile</Generator>
7069
<SubType>Designer</SubType>
@@ -109,10 +108,13 @@
109108
</ItemGroup>
110109
<ItemGroup>
111110
<PackageReference Include="Microsoft.Identity.Client">
112-
<Version>4.43.1</Version>
111+
<Version>4.53.0</Version>
112+
</PackageReference>
113+
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal">
114+
<Version>2.29.0</Version>
113115
</PackageReference>
114116
<PackageReference Include="Newtonsoft.Json">
115-
<Version>13.0.1</Version>
117+
<Version>13.0.3</Version>
116118
</PackageReference>
117119
</ItemGroup>
118120
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

2. Web API now calls Microsoft Graph/TodoListClient/TokenCacheHelper.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

2. Web API now calls Microsoft Graph/TodoListService/TodoListService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.8.0" />
15-
<PackageReference Include="Microsoft.Identity.Web" Version="2.8.0" />
14+
<PackageReference Include="Microsoft.Identity.Web.MicrosoftGraph" Version="2.10.0" />
15+
<PackageReference Include="Microsoft.Identity.Web" Version="2.10.0" />
1616
</ItemGroup>
1717

1818
</Project>

0 commit comments

Comments
 (0)