// ------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph { using System.Net.Http; using System.Threading.Tasks; /// /// Authenticate request async delegate. /// /// The to authenticate. /// public delegate Task AuthenticateRequestAsyncDelegate(HttpRequestMessage request); /// /// A default implementation. /// public class DelegateAuthenticationProvider : IAuthenticationProvider { /// /// Constructs an . /// public DelegateAuthenticationProvider(AuthenticateRequestAsyncDelegate authenticateRequestAsyncDelegate) { this.AuthenticateRequestAsyncDelegate = authenticateRequestAsyncDelegate; } /// /// Gets or sets the delegate for authenticating requests. /// public AuthenticateRequestAsyncDelegate AuthenticateRequestAsyncDelegate { get; set; } /// /// Authenticates the specified request message. /// /// The to authenticate. public Task AuthenticateRequestAsync(HttpRequestMessage request) { if (this.AuthenticateRequestAsyncDelegate != null) { return this.AuthenticateRequestAsyncDelegate(request); } return Task.FromResult(0); } } }