File tree 2 files changed +29
-1
lines changed 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System . Collections . Generic ;
6
+
5
7
namespace CommunityToolkit . Authentication
6
8
{
7
9
/// <summary>
@@ -19,6 +21,16 @@ public struct WebAccountProviderConfig
19
21
/// </summary>
20
22
public WebAccountProviderType WebAccountProviderType { get ; set ; }
21
23
24
+ /// <summary>
25
+ /// Gets or sets the properties that need to be added when constructing <see cref="Windows.Security.Authentication.Web.Core.WebTokenRequest"/> (for MSA).
26
+ /// </summary>
27
+ public IDictionary < string , string > MSATokenRequestProperties { get ; set ; }
28
+
29
+ /// <summary>
30
+ /// Gets or sets the properties that need to be added when constructing <see cref="Windows.Security.Authentication.Web.Core.WebTokenRequest"/> (for AAD).
31
+ /// </summary>
32
+ public IDictionary < string , string > AADTokenRequestProperties { get ; set ; }
33
+
22
34
/// <summary>
23
35
/// Initializes a new instance of the <see cref="WebAccountProviderConfig"/> struct.
24
36
/// </summary>
@@ -28,6 +40,8 @@ public WebAccountProviderConfig(WebAccountProviderType webAccountProviderType, s
28
40
{
29
41
WebAccountProviderType = webAccountProviderType ;
30
42
ClientId = clientId ;
43
+ MSATokenRequestProperties = new Dictionary < string , string > ( ) ;
44
+ AADTokenRequestProperties = new Dictionary < string , string > ( ) ;
31
45
}
32
46
}
33
47
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public class WindowsProvider : BaseProvider
33
33
private const string SettingsKeyProviderId = "WindowsProvider_ProviderId" ;
34
34
private const string SettingsKeyProviderAuthority = "WindowsProvider_Authority" ;
35
35
36
- private static readonly SemaphoreSlim SemaphoreSlim = new ( 1 ) ;
36
+ private static readonly SemaphoreSlim SemaphoreSlim = new ( 1 ) ;
37
37
38
38
// Default/minimal scopes for authentication, if none are provided.
39
39
private static readonly string [ ] DefaultScopes = { "User.Read" } ;
@@ -550,6 +550,20 @@ private WebTokenRequest GetWebTokenRequest(WebAccountProvider provider, string c
550
550
: new WebTokenRequest ( provider , scopesString , clientId ) ;
551
551
552
552
webTokenRequest . Properties . Add ( GraphResourcePropertyKey , GraphResourcePropertyValue ) ;
553
+ if ( provider . Authority == MicrosoftAccountAuthority )
554
+ {
555
+ foreach ( var property in _webAccountProviderConfig . MSATokenRequestProperties )
556
+ {
557
+ webTokenRequest . Properties . Add ( property ) ;
558
+ }
559
+ }
560
+ else if ( provider . Authority == AadAuthority )
561
+ {
562
+ foreach ( var property in _webAccountProviderConfig . AADTokenRequestProperties )
563
+ {
564
+ webTokenRequest . Properties . Add ( property ) ;
565
+ }
566
+ }
553
567
554
568
return webTokenRequest ;
555
569
}
You can’t perform that action at this time.
0 commit comments