File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System . Collections . Generic ;
6+
57namespace CommunityToolkit . Authentication
68{
79 /// <summary>
@@ -19,6 +21,16 @@ public struct WebAccountProviderConfig
1921 /// </summary>
2022 public WebAccountProviderType WebAccountProviderType { get ; set ; }
2123
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+
2234 /// <summary>
2335 /// Initializes a new instance of the <see cref="WebAccountProviderConfig"/> struct.
2436 /// </summary>
@@ -28,6 +40,8 @@ public WebAccountProviderConfig(WebAccountProviderType webAccountProviderType, s
2840 {
2941 WebAccountProviderType = webAccountProviderType ;
3042 ClientId = clientId ;
43+ MSATokenRequestProperties = new Dictionary < string , string > ( ) ;
44+ AADTokenRequestProperties = new Dictionary < string , string > ( ) ;
3145 }
3246 }
3347}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public class WindowsProvider : BaseProvider
3333 private const string SettingsKeyProviderId = "WindowsProvider_ProviderId" ;
3434 private const string SettingsKeyProviderAuthority = "WindowsProvider_Authority" ;
3535
36- private static readonly SemaphoreSlim SemaphoreSlim = new ( 1 ) ;
36+ private static readonly SemaphoreSlim SemaphoreSlim = new ( 1 ) ;
3737
3838 // Default/minimal scopes for authentication, if none are provided.
3939 private static readonly string [ ] DefaultScopes = { "User.Read" } ;
@@ -550,6 +550,20 @@ private WebTokenRequest GetWebTokenRequest(WebAccountProvider provider, string c
550550 : new WebTokenRequest ( provider , scopesString , clientId ) ;
551551
552552 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+ }
553567
554568 return webTokenRequest ;
555569 }
You can’t perform that action at this time.
0 commit comments