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 @@ namespace CommunityToolkit.Authentication } /// - 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 @@ namespace CommunityToolkit.Authentication 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..2e126e0 100644 --- a/CommunityToolkit.Authentication/IProvider.cs +++ b/CommunityToolkit.Authentication/IProvider.cs @@ -39,8 +39,9 @@ namespace CommunityToolkit.Authentication /// Retrieve a token for the authenticated user. /// /// Determines if the acquisition should be done without prompts to the user. + /// Optional param 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 @@ namespace CommunityToolkit.Authentication } /// - public override Task GetTokenAsync(bool silentOnly = false) + public override Task GetTokenAsync(bool silentOnly = false, string[] scopes = null) { return Task.FromResult(""); }