Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fc9d1c2
add products taxonomy to improve findability
kenanlv May 18, 2021
f4b8e3b
Hiding preview Graph docs in toc
shweaver-MSFT Jun 1, 2021
ea7ae0b
Graph doc updates
shweaver-MSFT Jun 2, 2021
511d367
Merge pull request #522 from kenanlv/master
mattwojo Jun 3, 2021
be7eb68
Update Getting-Started.md
Kyaa-dost Jun 7, 2021
1b815dd
Updates to providers overview
shweaver-MSFT Jun 7, 2021
6efe6c4
Adjusted file names and link paths
shweaver-MSFT Jun 7, 2021
5eeda86
Added constructor details to Msal/Windows providers.
shweaver-MSFT Jun 7, 2021
9bc6146
Merge pull request #532 from Kyaa-dost/Update-InstallationInstructions
michael-hawker Jun 8, 2021
9fa0ac1
Updated graph controls documentation
shweaver-MSFT Jun 8, 2021
74b0ec5
Small tweaks
shweaver-MSFT Jun 8, 2021
2c02c00
Fixed link typo
shweaver-MSFT Jun 8, 2021
9ce34f9
Lint fixes
shweaver-MSFT Jun 8, 2021
75bfd51
updated getting started headers
shweaver-MSFT Jun 8, 2021
49514c8
Added redirect configuration
shweaver-MSFT Jun 8, 2021
7cb390a
Updated toc
shweaver-MSFT Jun 8, 2021
340a93f
OnDeviceExtention: Remove examples section
Rosuavio Jun 9, 2021
80d0e2b
Updated redirection json
shweaver-MSFT Jun 9, 2021
fbd8eb6
Update docs/graph/authentication/overview.md
shweaver-MSFT Jun 10, 2021
a326bf7
Updated graph docs with new ProviderManager events
shweaver-MSFT Jun 11, 2021
e3f4b9b
Merge branch 'shweaver/graph-updates' of https://github.com/shweaver-…
shweaver-MSFT Jun 11, 2021
d319916
Lint fix
shweaver-MSFT Jun 11, 2021
12ff279
Update docs/graph/authentication/msal.md with missing link
michael-hawker Jun 15, 2021
87d40d5
Merge pull request #533 from shweaver-MSFT/shweaver/graph-updates
michael-hawker Jun 15, 2021
39c66ad
Merge pull request #535 from RosarioPulella/ondevice-no-unit-tests
michael-hawker Jun 15, 2021
10158df
fix msprod value
mattwojo Jun 18, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"redirections": [
{
"source_path": "archive/graph/providers/InteractiveProviderBehavior.md",
"redirect_url": "/graph/providers/interactiveproviderbehavior",
"redirect_document_id": true
},
{
"source_path": "archive/graph/providers/MockProviderBehavior.md",
"redirect_url": "/graph/providers/mockproviderbehavior",
"redirect_document_id": true
},
{
"source_path": "graph/authentication/msal.md",
"redirect_url": "/graph/authentication/msalprovider",
"redirect_document_id": true
},
{
"source_path": "graph/authentication/windows.md",
"redirect_url": "/graph/authentication/windowsprovider",
"redirect_document_id": true
},
{
"source_path": "graph/authentication/custom.md",
"redirect_url": "/graph/authentication/iprovider",
"redirect_document_id": true
}
]
}
2 changes: 1 addition & 1 deletion docs/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The toolkit is available as NuGet packages that can be added to any existing or
> [!NOTE]
> Visual Studio 2015 is not supported with the Windows Community Toolkit 2.0 or higher

2. Open an existing project, or create a new project using the Blank App template under Visual C# -> Windows -> Universal. **Important**: Build 16299 or higher is supported by current version of the Toolkit.
2. Open an existing project, or create a new project using the Blank App template under Visual C# -> Windows -> Universal. **Important**: Version 1809 (Build 17763) or higher is supported by current version of the Toolkit.

3. In Solution Explorer panel, right click on your project name and select **Manage NuGet Packages**. Search for **Microsoft.Toolkit.UWP**, and choose your desired [NuGet Packages](Nuget-Packages.md) from the list.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dev_langs:
# InteractiveProviderBehavior XAML Behavior

> [!WARNING]
> This API has been removed. For the latest guidance on using the Microsoft Graph in the Toolkit check out the [Windows Community Toolkit - Graph Helpers and Controls](../overview.md).
> This API has been removed. For the latest guidance on using the Microsoft Graph in the Toolkit check out the [Windows Community Toolkit - Graph Helpers and Controls](../../../graph/overview.md).

The [InteractiveProviderBehavior](/dotnet/api/microsoft.toolkit.graph.providers.interactiveproviderbehavior) provides a quick and easy way to connect to the Microsoft Identity platform and Microsoft Graph. It is built on top of the Graph SDK's authentication providers, but allows usage from XAML.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dev_langs:
# MockProviderBehavior XAML Behavior

> [!WARNING]
> This API has been removed. For the latest guidance on using the Microsoft Graph in the Toolkit check out the [Windows Community Toolkit - Graph Helpers and Controls](../overview.md).
> This API has been removed. For the latest guidance on using the Microsoft Graph in the Toolkit check out the [Windows Community Toolkit - Graph Helpers and Controls](../../../graph/overview.md).

<!-- Describe your control -->
The [MockProviderBehavior](/dotnet/api/microsoft.toolkit.graph.providers.mockproviderbehavior) provides sample data from the Microsoft Graph for demonstration and learning purposes only.
Expand Down
1 change: 1 addition & 0 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"uhfHeaderId": "MSDocsHeader-UWP-Community",
"ms.topic": "article",
"ms.prod": "community-toolkit",
"products": ["https://authoring-docs-microsoft.poolparty.biz/devrel/bcbcbad5-4208-4783-8035-8481272c98b8"],
"keywords": "windows uwp community toolkit",
"author": "michael-hawker",
"ms.author": "mhawker",
Expand Down
4 changes: 0 additions & 4 deletions docs/extensions/OnDeviceExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ Here is how the property can be used in XAML:
Text="{ui:OnDevice Default=Hi, Desktop=Hello, Xbox=World}"/>

```

## Examples

You can find more examples in the [unit tests](https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/rel/7.0.0/UnitTests).
68 changes: 0 additions & 68 deletions docs/graph/authentication/MsalProvider.md

This file was deleted.

56 changes: 10 additions & 46 deletions docs/graph/authentication/ProviderManager.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,13 @@ dev_langs:

# ProviderManager

The ProviderManager manages access to the globally configured [IProvider](./IProvider.md) instance and any state change events as users sign in and out.
The ProviderManager manages access to the globally configured [IProvider](./custom.md) instance and any state change events as users sign in and out.

> Available in the `CommunityToolkit.Authentication` package.

> [!IMPORTANT]
> Windows Community Toolkit - Graph Controls and Helpers packages are in preview. To get started using WCT preview packages visit the [WCT Preview Packages wiki page](https://aka.ms/wct/wiki/previewpackages).

## Set the GlobalProvider

```csharp
using CommunityToolkit.Authentication;

ProviderManager.Instance.GlobalProvider = new WindowsProvider();
```

## Listen for changes to the GlobalProvider

```csharp
using CommunityToolkit.Authentication;

ProviderManager.Instance.ProviderUpdated += OnProviderUpdated;

void OnProviderUpdated(object sender, ProviderUpdatedEventArgs e)
{
if (e.Reason == ProviderManagerChangedState.ProviderUpdated)
{
// The GlobalProvider has been set.
}

if (e.Reason == ProviderManagerChangedState.ProviderStateChanged)
{
// The GlobalProvider state has changed.
}
}
```

## Properties

| Property | Type | Description |
Expand All @@ -55,27 +26,20 @@ void OnProviderUpdated(object sender, ProviderUpdatedEventArgs e)

| Event | Type | Description |
| -- | -- | -- |
| ProviderUpdated | EventHandler&lt;ProviderUpdatedEventArgs&gt; | Event called when the IProvider changes. |

## Methods

| Method | Arguments | Returns | Description |
| -- | -- | -- | -- |
| AuthenticateRequestAsync | HttpRequestMessage | Task | Authenticate an outgoing request. |
| GetTokenAsync | bool silentOnly = true | Task&lt;string&gt; | Retrieve a token for the authenticated user. |
| SignInAsync | | Task | Sign in a user. |
| SignOutAsync | | Task | Sign out the current user. |
| TrySilentSignInAsync | | Task&lt;bool&gt; | Try signing in silently, without prompts. |
| ProviderUpdated | EventHandler&lt;IProvider&gt; | Event called when the IProvider changes. |
| ProviderStateChanged | EventHandler&lt;ProviderStateChangedEventArgs&gt; | Event called when the IProvider changes. |

## ProviderUpdatedEventArgs Object
## ProviderStateChangedEventArgs Object

| Property | Type | Description |
| -- | -- | -- |
| Reason | ProviderManagerChangedState | Gets the reason for the provider update. |
| OldState | ProviderState | Gets the previous state of the IProvider.
| NewState | ProviderState | Gets the new state of the IProvider.

## ProviderManagerChangedState Enum
## ProviderState Enum

| Name | Description |
| -- | -- |
| ProviderStateChanged | The [IProvider](./IProvider.md) state has changed.|
| ProviderUpdated | The [IProvider](./IProvider.md) itself has changed. |
| Loading | The user's status is not known. |
| SignedOut | The user is signed-out. |
| SignedIn | The user is signed-in. |
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ dev_langs:
- csharp
---

# IProvider
# Custom provider

The IProvider is the base interface for creating authentication providers that work with the various controls and helpers in the toolkit.
If you have existing authentication code in your application, you can create a custom provider to enable authentication and access to Microsoft Graph for the toolkit's Graph based controls and helpers. To bring your own authentication provider logic, start by extending `IProvider`.

## IProvider

`IProvider` is the base interface for creating authentication providers that work with the various controls and helpers in the toolkit. Handle authenticaiton with one of our premade `IProvider` implementations or create your own.

> Available in the `CommunityToolkit.Authentication` package.

Expand All @@ -19,47 +23,31 @@ The IProvider is the base interface for creating authentication providers that w
```csharp
using CommunityToolkit.Authentication;

IProvider provider = ProviderManager.Instance.GlobalProvider;
// Create an instance of your custom IProvider implementation.
IProvider customProvider = new CustomProvider();

if (provider?.State == ProviderState.SignedIn)
{
// You are now signed in and can request access tokens.
}
// Set the global provider using the custom instance.
ProviderManager.Instance.GlobalProvider = customProvider;
```

## Properties
### Properties

| Property | Type | Description |
| -- | -- | -- |
| State | ProviderState | Gets the current authentication state of the provider. |

## Events
### Events

| Event | Type | Description |
| -- | -- | -- |
| StateChanged | EventHandler&lt;ProviderStateChangedEventArgs&gt; | An event that is called whenever the login state changes.

## Methods
### Methods

| Method | Arguments | Returns | Description |
| -- | -- | -- | -- |
| AuthenticateRequestAsync | HttpRequestMessage | Task | Authenticate an outgoing request. |
| GetTokenAsync | bool silentOnly = true | Task&lt;string&gt; | Retrieve a token for the authenticated user. |
| GetTokenAsync | bool silentOnly = false, string[] scopes = null | Task&lt;string&gt; | Retrieve a token for the authenticated user. |
| SignInAsync | | Task | Sign in a user. |
| SignOutAsync | | Task | Sign out the current user. |
| TrySilentSignInAsync | | Task&lt;bool&gt; | Try signing in silently, without prompts. |

## ProviderStateChangedEventArgs Object

| Property | Type | Description |
| -- | -- | -- |
| OldState | ProviderState | Gets the previous state of the IProvider.
| NewState | ProviderState | Gets the new state of the IProvider.

## ProviderState Enum

| Name | Description |
| -- | -- |
| Loading | The user's status is not known. |
| SignedOut | The user is signed-out. |
| SignedIn | The user is signed-in. |
64 changes: 64 additions & 0 deletions docs/graph/authentication/msal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: MsalProvider
author: shweaver-MSFT
description: Authentication provider based on the official Microsoft Authentication Library (MSAL).
keywords: uwp, wpf, netstandard, windows, community, toolkit, graph, login, authentication, provider, providers, identity, msal
dev_langs:
- csharp
---

# MsalProvider

The MsalProvider is an [IProvider](./custom.md) implementation built on the official Microsoft Authentication Library (MSAL). It is NetStandard 2.0 so it works in both UWP and WPF apps.

> Available in the `CommunityToolkit.Authentication.Msal` package.

> [!IMPORTANT]
> Windows Community Toolkit - Graph Controls and Helpers packages are in preview. To get started using WCT preview packages visit the [WCT Preview Packages wiki page](https://aka.ms/wct/wiki/previewpackages).

```csharp
using CommunityToolkit.Authentication;

string clientId = "YOUR-CLIENT-ID-HERE";
string[] scopes = new string[] { "User.Read" };

ProviderManager.Instance.GlobalProvider = new MsalProvider(clientId, scopes);
```

## Prerequisite Configure Client Id in Partner Center

> [!IMPORTANT]
> To obtain a Client Id, first register your app in Azure following the guidance here: [Quickstart: Register an application with the Microsoft identity platform](/azure/active-directory/develop/quickstart-register-app)
>
> After finishing the initial registration, you will also need to add an additional redirect URI. Click on "Authentication -> Add a Platform", select "Mobile and desktop applications", and check the "https://login.microsoftonline.com/common/oauth2/nativeclient" checkbox on that page. Then click "Configure".

## Constructor

| Parameter | Type | Default | Description |
| -- | -- | -- | -- |
| clientId | string | | Registered client id. |
| scopes | string[] | null | Listof scopes to initially request. |
| redirectUri | string | `https://login.microsoftonline.com/common/oauth2/nativeclient` | Redirect URI for authentication response. |
| autoSignIn | bool | true | Determines whether the provider attempts to silently log in upon instantiation. |

## Properties

| Property | Type | Description |
| -- | -- | -- |
| State | ProviderState | Gets the current authentication state of the provider. |

## Events

| Event | Type | Description |
| -- | -- | -- |
| StateChanged | EventHandler&lt;ProviderStateChangedEventArgs&gt; | Event called when the provider state changes. |

## Methods

| Method | Arguments | Returns | Description |
| -- | -- | -- | -- |
| GetTokenAsync | bool silentOnly = false, string[] scopes = null | Task&lt;string&gt; | Retrieve a token for the authenticated user. |
| AuthenticateRequestAsync | HttpRequestMessage | Task | Authenticate an outgoing request. |
| SignInAsync | | Task | Sign in a user. |
| SignOutAsync | | Task | Sign out the current user. |
| TrySilentSignInAsync | | Task&lt;bool&gt; | Try signing in silently, without prompts. |
Loading