Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph doc updates post bug bash #533

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
}
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should redirect the MsalProvider too, eh?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I did rename the MsalProvider, WindowsPRovider, and IProvider files. I'll add them to redirect as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some details on "redirect_document_id" property:

redirect_document_id indicates whether you would like to keep the document ID from the previous file. The default is false. Use true if you want to preserve the ms.documentid attribute value from the redirected article. If you preserve the document ID, data, such as page views and rankings, will be transferred to the target article. Do this if the redirect is primarily a rename, and not a pointer to different article that only covers some of the same content.

So based on this info, I also flipped all of the "return_document_id" values to true because they are caused by file renames, and not pointers to different articles.

}
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
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