From 3f734a4dc9e3368c32252bd5243850d180d4f897 Mon Sep 17 00:00:00 2001 From: Shane Weaver Date: Mon, 12 Jul 2021 14:59:14 -0700 Subject: [PATCH 1/2] Removed scopes param from IProvider.GetTokenAsync --- CommunityToolkit.Authentication.Msal/MsalProvider.cs | 2 +- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 2 +- CommunityToolkit.Authentication/BaseProvider.cs | 2 +- CommunityToolkit.Authentication/IProvider.cs | 3 +-- CommunityToolkit.Authentication/MockProvider.cs | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CommunityToolkit.Authentication.Msal/MsalProvider.cs b/CommunityToolkit.Authentication.Msal/MsalProvider.cs index d58cc20..f137bb6 100644 --- a/CommunityToolkit.Authentication.Msal/MsalProvider.cs +++ b/CommunityToolkit.Authentication.Msal/MsalProvider.cs @@ -119,7 +119,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 tokenScopes = scopes ?? Scopes; diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index b80e0ec..c1b9992 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -169,7 +169,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) 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(""); } From 771b25f5a3406b9b91747083970bbb7bfb1a42b9 Mon Sep 17 00:00:00 2001 From: Shane Weaver Date: Mon, 12 Jul 2021 16:52:19 -0700 Subject: [PATCH 2/2] Removed references to scope param --- CommunityToolkit.Authentication.Msal/MsalProvider.cs | 6 ++---- CommunityToolkit.Authentication.Uwp/WindowsProvider.cs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CommunityToolkit.Authentication.Msal/MsalProvider.cs b/CommunityToolkit.Authentication.Msal/MsalProvider.cs index f137bb6..b871901 100644 --- a/CommunityToolkit.Authentication.Msal/MsalProvider.cs +++ b/CommunityToolkit.Authentication.Msal/MsalProvider.cs @@ -121,15 +121,13 @@ public override async Task SignOutAsync() /// 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) { 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 c1b9992..5847971 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -181,10 +181,8 @@ public override async Task GetTokenAsync(bool silentOnly = false) 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) @@ -196,7 +194,7 @@ public override async Task GetTokenAsync(bool silentOnly = false) } // Attempt to authenticate interactively. - authResult = await AuthenticateInteractiveAsync(tokenScopes); + authResult = await AuthenticateInteractiveAsync(_scopes); } if (authResult?.ResponseStatus == WebTokenRequestStatus.Success)