|
1 |
| ---- |
2 |
| -title: AadLogin Control |
3 |
| -author: OGcanviz |
4 |
| -description: The AadLogin Control leverages existing .NET login libraries to support basic AAD sign-in processes for Microsoft Graph. |
5 |
| -keywords: windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, AadLogin Control |
6 |
| ---- |
7 |
| - |
8 |
| -# AadLogin Control |
9 |
| - |
10 |
| -The [AadLogin Control](https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.ui.controls.graph.aadlogin) leverages existing .NET login libraries to support basic AAD sign-in processes for Microsoft Graph, it relies on the [MicrosoftGraphService](../services/MicrosoftGraph.md) for authentication. |
11 |
| - |
12 |
| -> [!div class="nextstepaction"] |
13 |
| -> [Try it in the sample app](uwpct://Controls?sample=AadLogin) |
14 |
| -
|
15 |
| -## Syntax |
16 |
| - |
17 |
| -```xaml |
18 |
| -<Page ... |
19 |
| - xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls.Graph"/> |
20 |
| - |
21 |
| -<controls:AadLogin x:Name="AADLogin1" |
22 |
| - View="PictureOnly" |
23 |
| - AllowSignInAsDifferentUser="True" /> |
24 |
| -``` |
25 |
| - |
26 |
| -## Example Image |
27 |
| - |
28 |
| - |
29 |
| - |
30 |
| -## Properties |
31 |
| - |
32 |
| -| Property | Type | Description | |
33 |
| -| -- | -- | -- | |
34 |
| -| RequiredDelegatedPermissions | String[] | Gets required delegated permissions for Graph API access | |
35 |
| -| DefaultImage | BitmapImage | The default image displayed when no user is signed in | |
36 |
| -| View | [ViewType](https://github.com/Microsoft/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/ProfileCard/ViewType.cs) | The visual layout of the control. Default is `PictureOnly` | |
37 |
| -| AllowSignInAsDifferentUser | Boolean | Whether or not the menu item for `Sign in as a different user` is enabled, default value is true | |
38 |
| -| SignInDefaultText | String | Default text for sign in button | |
39 |
| -| SignOutDefaultText | String | Default text for sign out button | |
40 |
| -| SignInAnotherUserDefaultText | String | Default text for `Sign in with another account` button | |
41 |
| -| CurrentUserId | String | Gets the unique identifier for current signed in user | |
42 |
| - |
43 |
| -## Methods |
44 |
| - |
45 |
| -| Method | Return Type | Description | |
46 |
| -| -- | -- | -- | |
47 |
| -| SignInAsync | bool | Method to call when to trigger the user signin. UX of the control is updated if successful. Returns false if the user cancels sign in | |
48 |
| -| SignOut | void | Method to call to signout the currently signed on user | |
49 |
| - |
50 |
| -## Events |
51 |
| - |
52 |
| -| Method | Type | Description | |
53 |
| -| -- | -- | -- | |
54 |
| -| SignInCompleted | EventHandler<SignInEventArgs> | Occurs when a user signs in | |
55 |
| -| SignInFailed | EventHandler<SignInFailedEventArgs> | Obsolete. Occurs when sign in failed when attempting to sign in. Only fires when an exception occurs during the sign in process and not when the user cancels sign in. | |
56 |
| -| SignOutCompleted | EventHandler | Occurs when the user clicks on SignOut, or the SignOut() method is called. Developers should clear any cached usage of GraphServiceClient objects they receive this event | |
57 |
| - |
58 |
| -## Sample Code |
59 |
| - |
60 |
| -First of all, initialize the [MicrosoftGraphService](../services/MicrosoftGraph.md) with your [Azure AD v2.0 app](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-app-registration), this should be done globally with the combined and unique [delegate permissions](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-scopes) required by all Graph controls and services used in your app. |
61 |
| - |
62 |
| -```c# |
63 |
| -MicrosoftGraphService.Instance.AuthenticationModel = MicrosoftGraphEnums.AuthenticationModel.V2; |
64 |
| - |
65 |
| -MicrosoftGraphService.Instance.Initialize( |
66 |
| - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", |
67 |
| - MicrosoftGraphEnums.ServicesToInitialize.UserProfile, |
68 |
| - AadLogin.RequiredDelegatedPermissions |
69 |
| -); |
70 |
| -``` |
71 |
| - |
72 |
| -[AadLogin Sample Page Source](https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AadLogin). You can [see this in action](uwpct://Controls?sample=AadLogin) in the [Windows Community Toolkit Sample App](http://aka.ms/uwptoolkitapp). |
73 |
| - |
74 |
| -## Default Template |
75 |
| - |
76 |
| -[AadLogin XAML File](https://github.com/Microsoft/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/AadLogin/AadLogin.xaml) is the XAML template used in the toolkit for the default styling. |
77 |
| - |
78 |
| -## Requirements |
79 |
| - |
80 |
| -| Device family | Universal, 10.0.16299.0 or higher | |
81 |
| -| -- | -- | |
82 |
| -| Namespace | Microsoft.Toolkit.Uwp.UI.Controls.Graph | |
83 |
| -| NuGet package | [Microsoft.Toolkit.Uwp.UI.Controls.Graph](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.UI.Controls.Graph/) | |
84 |
| - |
85 |
| -## API |
86 |
| - |
87 |
| -* [AadLogin source code](https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/AadLogin) |
| 1 | +--- |
| 2 | +title: AadLogin Control |
| 3 | +author: OGcanviz |
| 4 | +description: The AadLogin Control leverages existing .NET login libraries to support basic AAD sign-in processes for Microsoft Graph. |
| 5 | +keywords: windows 10, uwp, windows community toolkit, uwp community toolkit, uwp toolkit, AadLogin Control |
| 6 | +--- |
| 7 | + |
| 8 | +# AadLogin Control |
| 9 | + |
| 10 | +The [AadLogin Control](https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.ui.controls.graph.aadlogin) leverages existing .NET login libraries to support basic AAD sign-in processes for Microsoft Graph, it relies on the [MicrosoftGraphService](../../services/MicrosoftGraph.md) for authentication. |
| 11 | + |
| 12 | +## Syntax |
| 13 | + |
| 14 | +```xaml |
| 15 | +<Page ... |
| 16 | + xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls.Graph"/> |
| 17 | + |
| 18 | +<controls:AadLogin x:Name="AADLogin1" |
| 19 | + View="PictureOnly" |
| 20 | + AllowSignInAsDifferentUser="True" /> |
| 21 | +``` |
| 22 | + |
| 23 | +## Example Image |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +## Properties |
| 28 | + |
| 29 | +| Property | Type | Description | |
| 30 | +| -- | -- | -- | |
| 31 | +| RequiredDelegatedPermissions | String[] | Gets required delegated permissions for Graph API access | |
| 32 | +| DefaultImage | BitmapImage | The default image displayed when no user is signed in | |
| 33 | +| View | [ViewType](https://github.com/Microsoft/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/ProfileCard/ViewType.cs) | The visual layout of the control. Default is `PictureOnly` | |
| 34 | +| AllowSignInAsDifferentUser | Boolean | Whether or not the menu item for `Sign in as a different user` is enabled, default value is true | |
| 35 | +| SignInDefaultText | String | Default text for sign in button | |
| 36 | +| SignOutDefaultText | String | Default text for sign out button | |
| 37 | +| SignInAnotherUserDefaultText | String | Default text for `Sign in with another account` button | |
| 38 | +| CurrentUserId | String | Gets the unique identifier for current signed in user | |
| 39 | + |
| 40 | +## Methods |
| 41 | + |
| 42 | +| Method | Return Type | Description | |
| 43 | +| -- | -- | -- | |
| 44 | +| SignInAsync | bool | Method to call when to trigger the user signin. UX of the control is updated if successful. Returns false if the user cancels sign in | |
| 45 | +| SignOut | void | Method to call to signout the currently signed on user | |
| 46 | + |
| 47 | +## Events |
| 48 | + |
| 49 | +| Method | Type | Description | |
| 50 | +| -- | -- | -- | |
| 51 | +| SignInCompleted | EventHandler<SignInEventArgs> | Occurs when a user signs in | |
| 52 | +| SignInFailed | EventHandler<SignInFailedEventArgs> | Obsolete. Occurs when sign in failed when attempting to sign in. Only fires when an exception occurs during the sign in process and not when the user cancels sign in. | |
| 53 | +| SignOutCompleted | EventHandler | Occurs when the user clicks on SignOut, or the SignOut() method is called. Developers should clear any cached usage of GraphServiceClient objects they receive this event | |
| 54 | + |
| 55 | +## Sample Code |
| 56 | + |
| 57 | +First of all, initialize the [MicrosoftGraphService](../../services/MicrosoftGraph.md) with your [Azure AD v2.0 app](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-app-registration), this should be done globally with the combined and unique [delegate permissions](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-scopes) required by all Graph controls and services used in your app. |
| 58 | + |
| 59 | +```c# |
| 60 | +MicrosoftGraphService.Instance.AuthenticationModel = MicrosoftGraphEnums.AuthenticationModel.V2; |
| 61 | + |
| 62 | +MicrosoftGraphService.Instance.Initialize( |
| 63 | + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", |
| 64 | + MicrosoftGraphEnums.ServicesToInitialize.UserProfile, |
| 65 | + AadLogin.RequiredDelegatedPermissions |
| 66 | +); |
| 67 | +``` |
| 68 | + |
| 69 | +[AadLogin Sample Page Source](https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/AadLogin). You can [see this in action](uwpct://Controls?sample=AadLogin) in the [Windows Community Toolkit Sample App](http://aka.ms/uwptoolkitapp). |
| 70 | + |
| 71 | +## Default Template |
| 72 | + |
| 73 | +[AadLogin XAML File](https://github.com/Microsoft/WindowsCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/AadLogin/AadLogin.xaml) is the XAML template used in the toolkit for the default styling. |
| 74 | + |
| 75 | +## Requirements |
| 76 | + |
| 77 | +| Device family | Universal, 10.0.16299.0 or higher | |
| 78 | +| -- | -- | |
| 79 | +| Namespace | Microsoft.Toolkit.Uwp.UI.Controls.Graph | |
| 80 | +| NuGet package | [Microsoft.Toolkit.Uwp.UI.Controls.Graph](https://www.nuget.org/packages/Microsoft.Toolkit.Uwp.UI.Controls.Graph/) | |
| 81 | + |
| 82 | +## API |
| 83 | + |
| 84 | +* [AadLogin source code](https://github.com/Microsoft/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls.Graph/AadLogin) |
0 commit comments