Skip to content

Commit 9736890

Browse files
authored
Merge branch 'main' into patch-1
2 parents 64b2307 + e11fe16 commit 9736890

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

CommunityToolkit.Authentication.Msal/MsalProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ public override async Task SignOutAsync()
171171
}
172172

173173
/// <inheritdoc/>
174-
public override Task<string> GetTokenAsync(bool silentOnly = false)
174+
public override Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
175175
{
176-
return this.GetTokenWithScopesAsync(Scopes, silentOnly);
176+
var withScopes = scopes ?? this.Scopes;
177+
return this.GetTokenWithScopesAsync(withScopes, silentOnly);
177178
}
178179

179180
/// <summary>

CommunityToolkit.Authentication.Uwp/WindowsProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,17 @@ public override async Task SignOutAsync()
184184
}
185185

186186
/// <inheritdoc />
187-
public override async Task<string> GetTokenAsync(bool silentOnly = false)
187+
public override async Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
188188
{
189189
await SemaphoreSlim.WaitAsync();
190190

191191
try
192192
{
193-
var scopes = _scopes;
193+
// use request specific scopes if not null, otherwise use class scopes
194+
var authenticationScopes = scopes ?? this._scopes;
194195

195196
// Attempt to authenticate silently.
196-
var authResult = await AuthenticateSilentAsync(scopes);
197+
var authResult = await AuthenticateSilentAsync(authenticationScopes);
197198

198199
// Authenticate with user interaction as appropriate.
199200
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)

CommunityToolkit.Authentication/BaseProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public BaseProvider()
5252
public abstract Task AuthenticateRequestAsync(HttpRequestMessage request);
5353

5454
/// <inheritdoc />
55-
public abstract Task<string> GetTokenAsync(bool silentOnly = false);
55+
public abstract Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);
5656

5757
/// <inheritdoc />
5858
public abstract Task SignInAsync();

CommunityToolkit.Authentication/IProvider.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public interface IProvider
3939
/// Retrieve a token for the authenticated user.
4040
/// </summary>
4141
/// <param name="silentOnly">Determines if the acquisition should be done without prompts to the user.</param>
42+
/// <param name="scopes"> Optional parameter for setting scopes specific to this token request. </param>
4243
/// <returns>A token string for the authenticated user.</returns>
43-
Task<string> GetTokenAsync(bool silentOnly = false);
44+
Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null);
4445

4546
/// <summary>
4647
/// Sign in the user.

CommunityToolkit.Authentication/MockProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public override async Task AuthenticateRequestAsync(HttpRequestMessage request)
5252
}
5353

5454
/// <inheritdoc/>
55-
public override Task<string> GetTokenAsync(bool silentOnly = false)
55+
public override Task<string> GetTokenAsync(bool silentOnly = false, string[] scopes = null)
5656
{
5757
return Task.FromResult("<mock-provider-token>");
5858
}

0 commit comments

Comments
 (0)