diff --git a/CommunityToolkit.Authentication.Msal/MsalProvider.cs b/CommunityToolkit.Authentication.Msal/MsalProvider.cs index d58cc20..b871901 100644 --- a/CommunityToolkit.Authentication.Msal/MsalProvider.cs +++ b/CommunityToolkit.Authentication.Msal/MsalProvider.cs @@ -119,17 +119,15 @@ public override async Task SignOutAsync() } /// - public override async Task GetTokenAsync(bool silentOnly = false, string[] scopes = null) + public override async Task GetTokenAsync(bool silentOnly = false) { - var tokenScopes = scopes ?? Scopes; - AuthenticationResult authResult = null; try { var account = _account ?? (await Client.GetAccountsAsync()).FirstOrDefault(); if (account != null) { - authResult = await Client.AcquireTokenSilent(tokenScopes, account).ExecuteAsync(); + authResult = await Client.AcquireTokenSilent(Scopes, account).ExecuteAsync(); } } catch (MsalUiRequiredException) @@ -145,7 +143,7 @@ public override async Task GetTokenAsync(bool silentOnly = false, string { try { - authResult = await Client.AcquireTokenInteractive(tokenScopes).WithPrompt(Prompt.SelectAccount).ExecuteAsync(); + authResult = await Client.AcquireTokenInteractive(Scopes).WithPrompt(Prompt.SelectAccount).ExecuteAsync(); } catch { diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 851cf09..1f603f5 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -172,7 +172,7 @@ public override async Task SignOutAsync() } /// - public override async Task GetTokenAsync(bool silentOnly = false, string[] scopes = null) + public override async Task GetTokenAsync(bool silentOnly = false) { var internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (internetConnectionProfile == null) @@ -184,10 +184,8 @@ public override async Task GetTokenAsync(bool silentOnly = false, string try { - var tokenScopes = scopes ?? _scopes; - // Attempt to authenticate silently. - var authResult = await AuthenticateSilentAsync(tokenScopes); + var authResult = await AuthenticateSilentAsync(_scopes); // Authenticate with user interaction as appropriate. if (authResult?.ResponseStatus != WebTokenRequestStatus.Success) @@ -199,7 +197,7 @@ public override async Task GetTokenAsync(bool silentOnly = false, string } // Attempt to authenticate interactively. - authResult = await AuthenticateInteractiveAsync(tokenScopes); + authResult = await AuthenticateInteractiveAsync(_scopes); } if (authResult?.ResponseStatus == WebTokenRequestStatus.Success) diff --git a/CommunityToolkit.Authentication/BaseProvider.cs b/CommunityToolkit.Authentication/BaseProvider.cs index 4a0c5d5..cbeaeb6 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, string[] scopes = null); + public abstract Task GetTokenAsync(bool silentOnly = false); /// public abstract Task SignInAsync(); diff --git a/CommunityToolkit.Authentication/IProvider.cs b/CommunityToolkit.Authentication/IProvider.cs index eb9d657..cd065a2 100644 --- a/CommunityToolkit.Authentication/IProvider.cs +++ b/CommunityToolkit.Authentication/IProvider.cs @@ -39,9 +39,8 @@ public interface IProvider /// Retrieve a token for the authenticated user. /// /// Determines if the acquisition should be done without prompts to the user. - /// Additional scopes to request access for. /// A token string for the authenticated user. - Task GetTokenAsync(bool silentOnly = false, string[] scopes = null); + Task GetTokenAsync(bool silentOnly = false); /// /// Sign in the user. diff --git a/CommunityToolkit.Authentication/MockProvider.cs b/CommunityToolkit.Authentication/MockProvider.cs index 664d964..c3b5d99 100644 --- a/CommunityToolkit.Authentication/MockProvider.cs +++ b/CommunityToolkit.Authentication/MockProvider.cs @@ -46,7 +46,7 @@ public override Task AuthenticateRequestAsync(HttpRequestMessage request) } /// - public override Task GetTokenAsync(bool silentOnly = false, string[] scopes = null) + public override Task GetTokenAsync(bool silentOnly = false) { return Task.FromResult(""); }