From d44d6d023c7932d6edc1d862cc115e8e0d19e16e Mon Sep 17 00:00:00 2001 From: Shane Weaver Date: Wed, 1 Sep 2021 17:30:04 -0700 Subject: [PATCH] Removed network check in WindowsProvider --- .../WindowsProvider.cs | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs index 223a443..914e259 100644 --- a/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs +++ b/CommunityToolkit.Authentication.Uwp/WindowsProvider.cs @@ -8,7 +8,6 @@ using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; -using Windows.Networking.Connectivity; using Windows.Security.Authentication.Web; using Windows.Security.Authentication.Web.Core; using Windows.Security.Credentials; @@ -23,14 +22,6 @@ namespace CommunityToolkit.Authentication /// public class WindowsProvider : BaseProvider { - /// - /// Gets the redirect uri value based on the current app callback uri. - /// Used for configuring the Azure app registration. - /// - public static string RedirectUri => string.Format("ms-appx-web://Microsoft.AAD.BrokerPlugIn/{0}", WebAuthenticationBroker.GetCurrentApplicationCallbackUri().Host.ToUpper()); - - private static readonly SemaphoreSlim SemaphoreSlim = new(1); - private const string AuthenticationHeaderScheme = "Bearer"; private const string GraphResourcePropertyKey = "resource"; private const string GraphResourcePropertyValue = "https://graph.microsoft.com"; @@ -41,6 +32,8 @@ public class WindowsProvider : BaseProvider private const string SettingsKeyAccountId = "WindowsProvider_AccountId"; private const string SettingsKeyProviderId = "WindowsProvider_ProviderId"; + private static readonly SemaphoreSlim SemaphoreSlim = new (1); + // Default/minimal scopes for authentication, if none are provided. private static readonly string[] DefaultScopes = { "User.Read" }; @@ -48,6 +41,12 @@ public class WindowsProvider : BaseProvider // Default is Msa because it does not require any additional configuration private static readonly WebAccountProviderType DefaultWebAccountsProviderType = WebAccountProviderType.Msa; + /// + /// Gets the redirect uri value based on the current app callback uri. + /// Used for configuring the Azure app registration. + /// + public static string RedirectUri => string.Format("ms-appx-web://Microsoft.AAD.BrokerPlugIn/{0}", WebAuthenticationBroker.GetCurrentApplicationCallbackUri().Host.ToUpper()); + /// public override string CurrentAccountId => _webAccount?.Id; @@ -188,14 +187,6 @@ public override async Task GetTokenAsync(bool silentOnly = false) try { - var internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); - if (internetConnectionProfile == null) - { - // We are not online, no token for you. - // TODO: Is there anything special to do when we go offline? - return null; - } - var scopes = _scopes; // Attempt to authenticate silently.