Repository navigation
Expand file tree
/
Copy pathTwitterExtensions.cs
More file actions
32 lines (28 loc) · 1.51 KB
/
Copy pathTwitterExtensions.cs
File metadata and controls
32 lines (28 loc) · 1.51 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.Twitter;
using Microsoft.Extensions.Options;
namespace Microsoft.Extensions.DependencyInjection
{
public static class TwitterExtensions
{
/// <summary>
/// Adds Twitter authentication with options bound against the "Twitter" section
/// from the IConfiguration in the service container.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services)
{
services.AddSingleton<IConfigureOptions<TwitterOptions>, TwitterConfigureOptions>();
return services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, _ => { });
}
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, Action<TwitterOptions> configureOptions)
=> services.AddTwitterAuthentication(TwitterDefaults.AuthenticationScheme, configureOptions);
public static IServiceCollection AddTwitterAuthentication(this IServiceCollection services, string authenticationScheme, Action<TwitterOptions> configureOptions)
{
return services.AddScheme<TwitterOptions, TwitterHandler>(authenticationScheme, authenticationScheme, configureOptions);
}
}
}