You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/graph/authentication/ProviderManager.md
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -11,15 +11,14 @@ dev_langs:
11
11
12
12
The ProviderManager manages access to the globally configured [IProvider](./custom.md) instance and any state change events as users sign in and out.
13
13
14
-
> Available in the `CommunityToolkit.Authentication` package.
15
-
16
-
> [!IMPORTANT]
17
-
> 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).
14
+
Available in the `CommunityToolkit.Authentication` package.
18
15
19
16
## Properties
20
17
21
18
| Property | Type | Description |
22
19
| -- | -- | -- |
20
+
| ClientName | string | (*Static*) Gets the name of the toolkit client to identify self in Graph calls. |
21
+
| Instance | ProviderManager | (*Static*) Get or set the instance of the globally configured IProvider. |
23
22
| State | ProviderState | Gets the current authentication state of the provider. |
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`.
13
13
14
14
## IProvider
15
15
16
-
`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.
16
+
`IProvider` is the base interface for creating authentication providers that work with the various controls and helpers in the toolkit. Handle authentication with one of our premade `IProvider` implementations or create your own.
17
17
18
-
> Available in the `CommunityToolkit.Authentication` package.
19
-
20
-
> [!IMPORTANT]
21
-
> 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).
18
+
Available in the `CommunityToolkit.Authentication` package.
Copy file name to clipboardExpand all lines: docs/graph/authentication/msal.md
+1-4Lines changed: 1 addition & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,7 @@ dev_langs:
11
11
12
12
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.
13
13
14
-
> Available in the `CommunityToolkit.Authentication.Msal` package.
15
-
16
-
> [!IMPORTANT]
17
-
> 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).
14
+
Available in the `CommunityToolkit.Authentication.Msal` package.
Copy file name to clipboardExpand all lines: docs/graph/authentication/overview.md
+46-57Lines changed: 46 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,6 @@ dev_langs:
9
9
10
10
# Authentication Providers Overview
11
11
12
-
> [!IMPORTANT]
13
-
> 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).
14
-
15
12
Authentication is always the first step to working with Microsoft Graph. The toolkit providers enable your application to authenticate with Microsoft Identity and access Microsoft Graph in only few lines of code. Each provider handles user authentication and acquiring access tokens to call Microsoft Graph APIs, so that you don't have to write this code yourself.
16
13
17
14
You can use the providers on their own, without components, to quickly implement authentication for your app and make calls to Microsoft Graph via the Microsoft Graph .NET SDK.
@@ -22,9 +19,9 @@ The toolkit includes the following providers:
22
19
23
20
| Providers | Description |
24
21
| -- | -- |
25
-
|[Msal](./msal.md)| Uses MSAL for .NET to sign in users and acquire tokens to use with Microsoft Graph in a NetStandard 2.0 application. |
26
-
|[Windows](./windows.md)| Uses native WebAccountManager (WAM) APIs to sign in users and acquire tokens to use with Microsoft Graph in a UWP application. |
27
-
|[Custom](./custom.md)Custom| Create a custom provider to enable authentication and access to Microsoft Graph with your application's existing authentication code. |
22
+
|[Msal](./msal.md)| Uses MSAL for .NET to sign in users and acquire tokens to use with Microsoft Graph in NetStandard 2.0 applications. |
23
+
|[Windows](./windows.md)| Uses native WebAccountManager (WAM) APIs to sign in users and acquire tokens to use with Microsoft Graph in UWP applications. |
24
+
|[Custom](./custom.md)| Create a custom provider to enable authentication and access to Microsoft Graph with your application's existing authentication code. |
28
25
29
26
## Initializing the GlobalProvider
30
27
@@ -69,6 +66,8 @@ public enum ProviderState
69
66
}
70
67
```
71
68
69
+
## Respond to changes in the GlobalProvider state
70
+
72
71
In some scenarios, you will want to show certain functionality or perform an action only after a user has successfully signed in. You can access and check the provider state as shown in the following example:
73
72
74
73
```csharp
@@ -79,7 +78,7 @@ if (ProviderManager.Instance.GlobalProvider?.State === ProviderState.SignedIn) {
79
78
}
80
79
```
81
80
82
-
You can also use the `ProviderUpdated` and `ProviderStateChanged` events to get notified whenever provider is set or changes state.
81
+
Use the `ProviderUpdated` and `ProviderStateChanged` events to get notified whenever provider is set or changes state.
<!-- The pivot will only be visible when the global provider is in a signed in state, and otherwise collapsed. -->
134
+
</Pivot>
135
+
```
136
+
101
137
## Getting an access token
102
138
103
139
Each provider exposes a function called `getTokenAsync` that can retrieve the current access token or retrieve a new access token for the provided scopes. The following example shows how to get a new access token or the currently signed in user:
Once authenticated, you can now make API calls to Microsoft Graph using the Graph SDK or without.
152
+
Once authenticated, you can now make API calls to Microsoft Graph using the Graph SDK or without. See the [Extensions](../helpers/extensions.md) page for an example of how to authenticate an outbound request directly.
117
153
118
154
### Use the Graph SDK
119
155
120
-
Access APIs using the Graph SDK through a preconfigured `GraphServiceClient` available through an extension method on `IProvider` called,`GetClient()`.
156
+
Access APIs using the Graph SDK through a preconfigured `GraphServiceClient` available through an extension method on `IProvider` called `GetClient()` and `GetBetaClient()`.
121
157
See [Microsoft Graph Extensions](../helpers/extensions.md) for more details.
122
158
123
-
This is the easiest way to get started because all of the Graph types are available and the `GraphServiceClient` offers a convenient way of building requests.
159
+
It's possible to authenticate and make all Graph requests manually, without the Graph SDK. This can reduce package size significantly. However, using the Graph SDK is certainly the easiest way to work with Graph in .NET because the `GraphServiceClient` offers a convenient way of building requests and includes all of the object types ready to use.
124
160
125
161
Available in the `CommunityToolkit.Graph` package.
Access APIs by managing requests to Microsoft Graph yourself. This is helpful for projects with existing systems for managing web requests, or for keeping package sizes minimal by excluding the Graph SDK.
140
-
141
-
To make Graph API calls manually, use the `IProvider.AuthenticateRequestAsync(HttpRequestMessage)` method to authenticate an outgoing request.
Copy file name to clipboardExpand all lines: docs/graph/authentication/windows.md
+13-17Lines changed: 13 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,7 @@ dev_langs:
12
12
The WindowsProvider is an authentication provider for accessing locally configured accounts on Windows.
13
13
It extends [IProvider](./custom.md) and uses the native Windows AccountManager (WAM) APIs and AccountsSettingsPane for sign in.
14
14
15
-
> Available in the `CommunityToolkit.Authentication.Uwp` package.
16
-
17
-
> [!IMPORTANT]
18
-
> 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).
15
+
Available in the `CommunityToolkit.Authentication.Uwp` package.
19
16
20
17
## Prerequisite Windows Store Association in Visual Studio
21
18
@@ -30,27 +27,25 @@ To get valid tokens and complete sign in, the app will need to be associated wit
30
27
> [!NOTE]
31
28
> 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.
32
29
33
-
<!-- Uncomment this when AAD account support becomes available.
34
30
## Prerequisite Configure Client Id in Partner Center
35
31
36
32
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:
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.
41
37
42
38
> [!NOTE]
43
-
> 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.
39
+
> You only need to specify the client id if you need admin consent for delegated permissions from your AAD app registration, or need to support more advanced authentication scenarios like SSO. Simple authentication for consumer MSA accounts does not require a client id or any additional configuration in Azure for basic access.
44
40
45
41
> [!IMPORTANT]
46
-
> Be sure to Register Client Id in Azure first following the guidance here: <https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app>
42
+
> Make sure to Register Client Id in Azure first following the guidance here: [Quickstart: Register an application with the Microsoft identity platform](/azure/active-directory/develop/quickstart-register-app)
47
43
>
48
-
> 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`.
44
+
> 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` at runtime.
49
45
>
50
-
> You'll also want to set the toggle to true for "Allow public client flows".
46
+
> You'll also want to set the toggle to **true** for "Allow public client flows".
51
47
>
52
48
> Then click "Save".
53
-
-->
54
49
55
50
## Syntax
56
51
@@ -64,9 +59,8 @@ using CommunityToolkit.Authentication;
0 commit comments