예제 #1
0
        /// <summary>
        /// Registers Auth0.ManagementApi.IManagementApiClient and required types into the service collection object.
        /// </summary>
        /// <param name="services">Current service collection instance.</param>
        /// <param name="configureOptions">Extension point to provide options to the factory.</param>
        /// <returns></returns>
        public static IServiceCollection AddAuth0ManagementApi(
            this IServiceCollection services,
            Action <Auth0FactoryOptions> configureOptions)
        {
            var options = new Auth0FactoryOptions();

            configureOptions(options);

            services.AddSingleton(options);
            services.AddSingleton <IAuth0AccessTokenFactory>(
                serviceProvider => new Auth0AccessTokenFactory(options));
            services.AddSingleton <IAuth0ClientFactory>(
                serviceProvider => new Auth0ClientFactory(
                    options,
                    serviceProvider.GetRequiredService <IAuth0AccessTokenFactory>()));
            services.AddTransient(CreateManagementApi);

            return(services);
        }
 public Auth0ClientFactory(
     Auth0FactoryOptions options,
     IAuth0AccessTokenFactory auth0AccessTokenFactory) :
     this(options.Domain, auth0AccessTokenFactory)
 {
 }
 public Auth0AccessTokenFactory(
     Auth0FactoryOptions options,
     HttpClient httpClient = null) :
     this(options.Domain, options.ClientId, options.ClientSecret, options.ReuseAccessToken, httpClient)
 {
 }