Skip to content

Commit 5dcb983

Browse files
authored
Merge pull request #239 from Azure-Samples/jmprieur/fixPca
Fix the PCAs
2 parents d894b62 + da2bb25 commit 5dcb983

File tree

6 files changed

+37
-114
lines changed

6 files changed

+37
-114
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.53.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.

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.

0 commit comments

Comments
 (0)