/// <summary>
        /// Adds the scope metadata endpoint that will resolve the scope displayname/description. Default configuration.
        /// </summary>
        /// <typeparam name="TDynamicScopeNotificationService"></typeparam>
        /// <param name="builder">The <see cref="IIdentityServerBuilder"/> builder.</param>
        /// <param name="configureAction">Configures options for <see cref="IDynamicScopeNotificationService"/>.</param>
        public static IIdentityServerBuilder AddDynamicScopeNotifications <TDynamicScopeNotificationService>(this IIdentityServerBuilder builder, Action <DynamicScopeNotificationOptions> configureAction = null)
            where TDynamicScopeNotificationService : class, IDynamicScopeNotificationService
        {
            var existingService = builder.Services.Where(x => x.ServiceType == typeof(IDynamicScopeNotificationService)).LastOrDefault();

            if (existingService == null)
            {
                var configuration = builder.Services.BuildServiceProvider().GetRequiredService <IConfiguration>();
                var options       = new DynamicScopeNotificationOptions {
                    Endpoint = configuration["IdentityServer:ScopeNotificationEndpoint"]
                };
                configureAction?.Invoke(options);
                if (string.IsNullOrEmpty(options.Endpoint))
                {
                    throw new Exception($"Configuration for {nameof(AddDynamicScopeNotifications)} failed. Must provide a IdentityServer:ScopeNotificationEndpoint setting");
                }
                builder.Services.AddSingleton(options);
                builder.AddConsentServiceWithDynamicScopeNotifications();
                builder.AddPersistedGrantServiceWithDynamicScopeNotifications();
                builder.Services.AddHttpClient <IDynamicScopeNotificationService, TDynamicScopeNotificationService>()
                .SetHandlerLifetime(TimeSpan.FromMinutes(5));
            }
            return(builder);
        }