diff --git a/CommunityToolkit.Authentication/ProviderManager.cs b/CommunityToolkit.Authentication/ProviderManager.cs
index 0144f82..5bae3ea 100644
--- a/CommunityToolkit.Authentication/ProviderManager.cs
+++ b/CommunityToolkit.Authentication/ProviderManager.cs
@@ -61,9 +61,9 @@ public IProvider GlobalProvider
_provider.StateChanged += ProviderStateChanged;
}
- ProviderUpdated?.Invoke(this, new ProviderUpdatedEventArgs(ProviderManagerChangedState.ProviderChanged));
-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(GlobalProvider)));
+ ProviderUpdated?.Invoke(this, new ProviderUpdatedEventArgs(ProviderManagerChangedState.ProviderChanged));
+ ProviderUpdated?.Invoke(this, new ProviderUpdatedEventArgs(ProviderManagerChangedState.ProviderStateChanged));
}
}
diff --git a/Docs/QuickStart-WindowsProvider.md b/Docs/QuickStart-WindowsProvider.md
deleted file mode 100644
index ea6b4eb..0000000
--- a/Docs/QuickStart-WindowsProvider.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# How To: Quickly setup the WindowsProvider for authentication
-Here are some quick setup steps for using the WindowsProvider in a UWP app:
-
-1. Open Visual Studio and create a new C# UWP application.
-
-2. Add the following nuget packages (Nuget feed: [WindowsCommunityToolkit-MainLatest](https://pkgs.dev.azure.com/dotnet/WindowsCommunityToolkit/_packaging/WindowsCommunityToolkit-MainLatest/nuget/v3/index.json)):
- * `CommunityToolkit.Authentication.Uwp` – For the WindowsProvider
- * `CommunityToolkit.Graph.Uwp` – For the LoginButton
-
-3. Open the App.xaml.cs and add the following code to the bottom of the OnLaunched. You’ll need to make the method async as well.
-
-```
-// Find this line in the OnLaunched method and add the following code immediately after.
-Window.Current.Activate();
-
-string[] scopes = new string[] { "User.Read", "Tasks.ReadWrite" };
-ProviderManager.Instance.GlobalProvider = new WindowsProvider(scopes);
-```
-
-4. Add a LoginButton to the MainPage.xaml
-
-```
-xmlns:graphcontrols="using:CommunityToolkit.Graph.Uwp"
-
-
-```
-
-5. Associate the app to the Store in VS by selecting `Project` -> `Publish` -> `Associate App with the Store...` and following the prompts.
-
-6. Run the app and click the button to initiate login.
diff --git a/Docs/WindowsProvider.md b/Docs/WindowsProvider.md
deleted file mode 100644
index 4f72110..0000000
--- a/Docs/WindowsProvider.md
+++ /dev/null
@@ -1,119 +0,0 @@
-# WindowsProvider
-
-The WindowsProvider is an authentication provider for accessing locally configured accounts on Windows.
-It extends IProvider and uses the native AccountsSettingsPane APIs for login.
-
-## Syntax
-
-```CSharp
-// Provider config
-string clientId = "YOUR_CLIENT_ID_HERE"; // AAD configuration is only required for admin-level consent.
-string[] scopes = { "User.Read", "People.Read", "Calendars.Read", "Mail.Read" };
-bool autoSignIn = true;
-
-// Easily create a new WindowsProvider instance and set the GlobalProvider.
-// The provider will attempt to sign in automatically.
-ProviderManager.Instance.GlobalProvider = new WindowsProvider(scopes);
-
-// Additional parameters are also available,
-// such as custom settings commands for the AccountsSettingsPane.
-Guid settingsCommandId = Guid.NewGuid();
-void OnSettingsCommandInvoked(IUICommand command)
-{
- System.Diagnostics.Debug.WriteLine("AccountsSettingsPane command invoked: " + command.Id);
-}
-
-// Configure which types accounts should be available to choose from. The default is MSA, but AAD will come in the future.
-// ClientId is only required for approving admin level consent.
-var webAccountProviderConfig = new WebAccountProviderConfig(WebAccountProviderType.MSA, clientId);
-
-// Configure details to present in the AccountsSettingsPane, such as custom header text and links.
-var accountsSettingsPaneConfig = new AccountsSettingsPaneConfig(
- headerText: "Custom header text",
- commands: new List()
- {
- new SettingsCommand(settingsCommandId: settingsCommandId, label: "Click me!", handler: OnSettingsCommandInvoked)
- });
-
-// Determine it the provider should automatically sign in or not. Default is true.
-// Set to false to delay silent sign in until TrySilentSignInAsync is called.
-bool autoSignIn = false;
-
-// Set the GlobalProvider with the extra configuration
-ProviderManager.Instance.GlobalProvider = new WindowsProvider(scopes, accountsSettingsPaneConfig, webAccountProviderConfig, autoSignIn);
-```
-
-## Prerequisite Windows Store Association in Visual Studio
-To get valid tokens and complete login, the app will need to be associated with the Microsoft Store. This will enable your app to authenticate consumer MSA accounts without any additional configuration.
-
-1. In Visual Studio Solution Explorer, right-click the UWP project, then select **Store -> Associate App with the Store...**
-
-2. In the wizard, click **Next**, sign in with your Windows developer account, type a name for your app in **Reserve a new app name**, then click **Reserve**.
-
-3. After completing the app registration, select the new app name, click **Next**, and then click **Associate**. This adds the required Windows Store registration information to the application manifest.
-
-> [!NOTE]
-> You must have a Windows Developer account to use the WindowsProvider in your UWP app. You can [register a Microsoft developer account](https://developer.microsoft.com/store/register) if you don't already have one.
-
-
-## Prerequisite Configure Client Id in Partner Center
-
-If your product integrates with Azure AD and calls APIs that request either application permissions or delegated permissions that require administrator consent, you will also need to enter your Azure AD Client ID in Partner Center:
-
-https://partner.microsoft.com/en-us/dashboard/products/<YOUR-APP-ID>/administrator-consent
-
-This lets administrators who acquire the app for their organization grant consent for your product to act on behalf of all users in the tenant.
-
-> [!NOTE]
-> You only need to specify the client id if you need admin consent for delegated permissions from your AAD app registration. Simple authentication for public accounts does not require a client id or any additional configuration.
-
-> [!IMPORTANT]
-> Be sure to Register Client Id in Azure first following the guidance here:
->
-> After finishing the initial registration page, you will also need to add an additional redirect URI. Click on "Add a Redirect URI" and add the value retrieved from running `WindowsProvider.RedirectUri`.
->
-> You'll also want to set the toggle to true for "Allow public client flows".
->
-> Then click "Save".
-
-## Properties
-
-See IProvider for a full list of supported properties.
-
-| Property | Type | Description |
-| -- | -- | -- |
-| Scopes | string[] | List of scopes to pre-authorize on the user during authentication. |
-| WebAccountsProviderConfig | WebAccountsProviderConfig | configuration values for determining the available web account providers. |
-| AccountsSettingsPaneConfig | AccountsSettingsPaneConfig | Configuration values for the AccountsSettingsPane, shown during authentication. |
-| RedirectUri | string | Static getter for retrieving a customized redirect uri to put in the Azure app registration. |
-
-### WebAccountProviderConfig
-
-| Property | Type | Description |
-| -- | -- | -- |
-| ClientId | string | Client Id obtained from Azure registration. |
-| WebAccountsProviderType | WebAccountsProviderType | The types of accounts providers that should be available to the user. |
-
-### AccountsSettingsPaneConfig
-
-| Property | Type | Description |
-| -- | -- | -- |
-| HeaderText | string | Gets or sets the header text for the accounts settings pane. |
-| Commands | IList | Gets or sets the SettingsCommand collection for the account settings pane. |
-
-## Enums
-
-### WebAccountProviderType
-
-| Value | Description |
-| -- | -- |
-| MSA | Enable authentication of public/consumer MSA accounts. |
-
-## Methods
-
-See IProvider for a full list of supported methods.
-
-| Method | Arguments | Returns | Description |
-| -- | -- | -- | -- |
-| GetTokenAsync | bool silentOnly = true | Task | Retrieve a token for the authenticated user. |
-| TrySilentSignInAsync | | Task | Try logging in silently, without prompts. |
\ No newline at end of file
diff --git a/README.md b/README.md
index 59969a3..d9721d0 100644
--- a/README.md
+++ b/README.md
@@ -88,16 +88,20 @@ Once you are authenticated, you can then make requests to the Graph using the Gr
> Install the `CommunityToolkit.Graph` package.
-```
+```csharp
using CommunityToolkit.Authentication;
using CommunityToolkit.Graph.Extensions;
-var provider = ProviderManager.Instance.GlobalProvider;
+ProviderManager.Instance.ProviderUpdated += OnProviderUpdated;
-if (provider != null && provider.State == ProviderState.SignedIn)
+void OnProviderUpdated(object sender, ProviderUpdatedEventArgs e)
{
- var graphClient = provider.GetClient();
- var me = await graphClient.Me.Request().GetAsync();
+ var provider = ProviderMananager.Instance.GlobalProvider;
+ if (e.Reason == ProviderManagerChangedState.ProviderStateChanged && provider?.State == ProviderState.SignedIn)
+ {
+ var graphClient = provider.GetClient();
+ var me = await graphClient.Me.Request().GetAsync();
+ }
}
```
@@ -105,7 +109,7 @@ if (provider != null && provider.State == ProviderState.SignedIn)
Alternatively if you do not wish to use the Graph SDK you can make requests to Microsoft Graph manually instead:
-```
+```csharp
using CommunityToolkit.Authentication;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -168,9 +172,10 @@ public ImageSource GetMyPhoto()
}
catch
{
- return null;
}
}
+
+ return null;
}
```
diff --git a/UnitTests/UnitTests.UWP/RoamingSettings/Test_OneDriveDataStore.cs b/UnitTests/UnitTests.UWP/RoamingSettings/Test_OneDriveDataStore.cs
index 5f427f8..dd77580 100644
--- a/UnitTests/UnitTests.UWP/RoamingSettings/Test_OneDriveDataStore.cs
+++ b/UnitTests/UnitTests.UWP/RoamingSettings/Test_OneDriveDataStore.cs
@@ -139,7 +139,7 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
ProviderManager.Instance.ProviderUpdated += (s, e) =>
{
var providerManager = s as ProviderManager;
- if (providerManager.GlobalProvider.State == ProviderState.SignedIn)
+ if (e.Reason == ProviderManagerChangedState.ProviderStateChanged && providerManager.GlobalProvider.State == ProviderState.SignedIn)
{
test.Invoke();
}
diff --git a/UnitTests/UnitTests.UWP/RoamingSettings/Test_UserExtensionDataStore.cs b/UnitTests/UnitTests.UWP/RoamingSettings/Test_UserExtensionDataStore.cs
index 9c3b244..1a7d677 100644
--- a/UnitTests/UnitTests.UWP/RoamingSettings/Test_UserExtensionDataStore.cs
+++ b/UnitTests/UnitTests.UWP/RoamingSettings/Test_UserExtensionDataStore.cs
@@ -139,7 +139,7 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
ProviderManager.Instance.ProviderUpdated += (s, e) =>
{
var providerManager = s as ProviderManager;
- if (providerManager.GlobalProvider.State == ProviderState.SignedIn)
+ if (e.Reason == ProviderManagerChangedState.ProviderStateChanged && providerManager.GlobalProvider.State == ProviderState.SignedIn)
{
test.Invoke();
}
diff --git a/Windows-Toolkit-Graph-Controls.sln b/Windows-Toolkit-Graph-Controls.sln
index fc2a152..12933bc 100644
--- a/Windows-Toolkit-Graph-Controls.sln
+++ b/Windows-Toolkit-Graph-Controls.sln
@@ -35,12 +35,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests.UWP", "UnitTests\UnitTests.UWP\UnitTests.UWP.csproj", "{6B33B26C-008B-4ADB-B317-EF996CD6755B}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{EACBCDF3-8CCC-4A30-87E9-75FCA815831E}"
- ProjectSection(SolutionItems) = preProject
- Docs\QuickStart-WindowsProvider.md = Docs\QuickStart-WindowsProvider.md
- Docs\WindowsProvider.md = Docs\WindowsProvider.md
- EndProjectSection
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{022BF202-8D0D-4A6B-8A5B-92376D2EB5DA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UwpMsalProviderSample", "Samples\UwpMsalProviderSample\UwpMsalProviderSample.csproj", "{D0F6A1EB-806E-424A-BDCA-9F749F12774F}"