Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 2 KB

File metadata and controls

50 lines (36 loc) · 2 KB
title Custom authentication providers
author shweaver-MSFT
description IProvider interface defines the basic functions of an authentication provider in the Graph toolkit.
keywords uwp, wpf, netstandard, windows, community, toolkit, graph, login, authentication, provider, providers, identity
dev_langs
csharp

Custom authentication providers

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 authentication with one of our premade IProvider implementations or create your own.

Available in the CommunityToolkit.Authentication package.

using CommunityToolkit.Authentication;

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

// Set the global provider using the custom instance.
ProviderManager.Instance.GlobalProvider = customProvider;

Properties

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

Events

Event Type Description
StateChanged EventHandler<ProviderStateChangedEventArgs> An event that is called whenever the login state changes.

Methods

Method Arguments Returns Description
AuthenticateRequestAsync HttpRequestMessage Task Authenticate an outgoing request.
GetTokenAsync bool silentOnly = false Task<string> Retrieve a token for the authenticated user.
SignInAsync Task Sign in a user.
SignOutAsync Task Sign out the current user.
TrySilentSignInAsync Task<bool> Try signing in silently, without prompts.