AadLogin Control
Warning
(This API has been removed. For the latest guidance on using the Microsoft Graph see the LoginButton control.)
The AadLogin Control leverages existing .NET login libraries to support basic AAD sign-in processes for Microsoft Graph, it relies on the MicrosoftGraphService for authentication.
Syntax
<Page ...
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls.Graph"/>
<controls:AadLogin x:Name="AADLogin1"
View="PictureOnly"
AllowSignInAsDifferentUser="True" />
Example Image
Properties
Property | Type | Description |
---|---|---|
RequiredDelegatedPermissions | String[] | Gets required delegated permissions for Graph API access |
DefaultImage | BitmapImage | The default image displayed when no user is signed in |
View | ViewType | The visual layout of the control. Default is PictureOnly |
AllowSignInAsDifferentUser | Boolean | Whether or not the menu item for Sign in as a different user is enabled, default value is true |
SignInDefaultText | String | Default text for sign in button |
SignOutDefaultText | String | Default text for sign out button |
SignInAnotherUserDefaultText | String | Default text for Sign in with another account button |
CurrentUserId | String | Gets the unique identifier for current signed in user |
Methods
Method | Return Type | Description |
---|---|---|
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 |
SignOut | void | Method to call to signout the currently signed on user |
Events
Method | Type | Description |
---|---|---|
SignInCompleted | EventHandler<SignInEventArgs> | Occurs when a user signs in |
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. |
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 |
Sample Code
First of all, initialize the MicrosoftGraphService with your Azure AD v2.0 app, this should be done globally with the combined and unique delegate permissions required by all Graph controls and services used in your app.
MicrosoftGraphService.Instance.AuthenticationModel = MicrosoftGraphEnums.AuthenticationModel.V2;
MicrosoftGraphService.Instance.Initialize(
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
MicrosoftGraphEnums.ServicesToInitialize.UserProfile,
AadLogin.RequiredDelegatedPermissions
);
AadLogin Sample Page Source. You can see this in action in the Windows Community Toolkit Sample App.
Default Template
AadLogin XAML File is the XAML template used in the toolkit for the default styling.
Requirements
Device family | Universal, 10.0.16299.0 or higher |
---|---|
Namespace | Microsoft.Toolkit.Uwp.UI.Controls.Graph |
NuGet package | Microsoft.Toolkit.Uwp.UI.Controls.Graph |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for