Repository navigation
Expand file tree
/
Copy pathFacebookExtensions.cs
More file actions
32 lines (28 loc) · 1.54 KB
/
Copy pathFacebookExtensions.cs
File metadata and controls
32 lines (28 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Authentication.Facebook;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.DependencyInjection
{
public static class FacebookAuthenticationOptionsExtensions
{
/// <summary>
/// Adds facebook authentication with options bound against the "Facebook" section
/// from the IConfiguration in the service container.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services)
{
services.AddSingleton<IConfigureOptions<FacebookOptions>, FacebookConfigureOptions>();
return services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, _ => { });
}
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, Action<FacebookOptions> configureOptions)
=> services.AddFacebookAuthentication(FacebookDefaults.AuthenticationScheme, configureOptions);
public static IServiceCollection AddFacebookAuthentication(this IServiceCollection services, string authenticationScheme, Action<FacebookOptions> configureOptions)
{
return services.AddOAuthAuthentication<FacebookOptions, FacebookHandler>(authenticationScheme, configureOptions);
}
}
}