diff --git a/CommunityToolkit.Authentication.Msal/MsalProvider.cs b/CommunityToolkit.Authentication.Msal/MsalProvider.cs
index 3adf77a..9b90884 100644
--- a/CommunityToolkit.Authentication.Msal/MsalProvider.cs
+++ b/CommunityToolkit.Authentication.Msal/MsalProvider.cs
@@ -171,9 +171,10 @@ public override async Task SignOutAsync()
}
///
- public override Task GetTokenAsync(bool silentOnly = false)
+ public override Task GetTokenAsync(bool silentOnly = false, string[] scopes = null)
{
- return this.GetTokenWithScopesAsync(Scopes, silentOnly);
+ var withScopes = scopes ?? this.Scopes;
+ return this.GetTokenWithScopesAsync(withScopes, silentOnly);
}
///
diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs
index b0f1235..2a5434a 100644
--- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs
+++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs
@@ -184,16 +184,17 @@ public override async Task SignOutAsync()
}
///
- public override async Task GetTokenAsync(bool silentOnly = false)
+ public override async Task GetTokenAsync(bool silentOnly = false, string[] scopes = null)
{
await SemaphoreSlim.WaitAsync();
try
{
- var scopes = _scopes;
+ // use request specific scopes if not null, otherwise use class scopes
+ var authenticationScopes = scopes ?? this._scopes;
// Attempt to authenticate silently.
- var authResult = await AuthenticateSilentAsync(scopes);
+ var authResult = await AuthenticateSilentAsync(authenticationScopes);
// Authenticate with user interaction as appropriate.
if (authResult?.ResponseStatus != WebTokenRequestStatus.Success)
diff --git a/CommunityToolkit.Authentication/BaseProvider.cs b/CommunityToolkit.Authentication/BaseProvider.cs
index cbeaeb6..4a0c5d5 100644
--- a/CommunityToolkit.Authentication/BaseProvider.cs
+++ b/CommunityToolkit.Authentication/BaseProvider.cs
@@ -52,7 +52,7 @@ public BaseProvider()
public abstract Task AuthenticateRequestAsync(HttpRequestMessage request);
///
- public abstract Task GetTokenAsync(bool silentOnly = false);
+ public abstract Task GetTokenAsync(bool silentOnly = false, string[] scopes = null);
///
public abstract Task SignInAsync();
diff --git a/CommunityToolkit.Authentication/IProvider.cs b/CommunityToolkit.Authentication/IProvider.cs
index cd065a2..a9d0e84 100644
--- a/CommunityToolkit.Authentication/IProvider.cs
+++ b/CommunityToolkit.Authentication/IProvider.cs
@@ -39,8 +39,9 @@ public interface IProvider
/// Retrieve a token for the authenticated user.
///
/// Determines if the acquisition should be done without prompts to the user.
+ /// Optional parameter for setting scopes specific to this token request.
/// A token string for the authenticated user.
- Task GetTokenAsync(bool silentOnly = false);
+ Task GetTokenAsync(bool silentOnly = false, string[] scopes = null);
///
/// Sign in the user.
diff --git a/CommunityToolkit.Authentication/MockProvider.cs b/CommunityToolkit.Authentication/MockProvider.cs
index d66e63b..67e261d 100644
--- a/CommunityToolkit.Authentication/MockProvider.cs
+++ b/CommunityToolkit.Authentication/MockProvider.cs
@@ -52,7 +52,7 @@ public override async Task AuthenticateRequestAsync(HttpRequestMessage request)
}
///
- public override Task GetTokenAsync(bool silentOnly = false)
+ public override Task GetTokenAsync(bool silentOnly = false, string[] scopes = null)
{
return Task.FromResult("");
}