From November 21
to December 01
99Days : 99Hrs : 99Min : 99Sec
Also valid for the
existing customers!
Open Closed

How to get the danymic option manually? #2800

zhongfang created
  • ABP Framework version: v5.1.4
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no Abp provide a good way to configure dynamic optons for OAuth login. I can configure the valu for every tenant. And it is working. Every tenant can use it's own value while OAuth remote login.
            .AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { })
            .WithDynamicOptions<GoogleOptions, GoogleHandler>(
                options =>
                    options.WithProperty(x => x.ClientId);
                    options.WithProperty(x => x.ClientSecret, isSecret: true);

My question is How to get the danymic option manually? I wan't to use it in Volo.Abp.Account.Pro.Publick.Web.Pages.Accounts.Login.cshtml.cs I must use the values of the danymicoption in below stage.

        public virtual async Task<IActionResult> OnGetExternalLoginCallbackAsync(string returnUrl = "", string returnUrlHash = "", string remoteError = null)

3 Answer(s)
  • 0
    zhongfang created

    Oh, may I use as below?

    string providers= await this.SettingProvider.GetOrNullAsync("Abp.Account.ExternalProviders");
  • 0
    zhongfang created

    I wrote my functions to read the value I need. I am testing and waiting answers from you.

        namespace Yee.Change.Common.WebShared.IdentityServers
        using System;
        using System.Linq;
        using System.Text;
        using Newtonsoft.Json;
        using Volo.Abp.Settings;
        using System.Threading.Tasks;
        using System.Collections.Generic;
        public class SettingUtils
            public async Task<string> GetSetting(ISettingProvider settingProvider, string externalProviderSchema, string name)
                string json = await settingProvider.GetOrNullAsync("Abp.Account.ExternalProviders");
                if (string.IsNullOrWhiteSpace(json))
                    throw new Exception("json is null");
                List<ExternalProviderSettings> providers = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ExternalProviderSettings>>(json);
                ExternalProviderSettings externalProvider = providers.FirstOrDefault(p => p.Name == externalProviderSchema);
                PropertityInfo properti = externalProvider.Propertities.First(p => p.Name == name);
                if (properti != null)
                    return properti.Value;
                return string.Empty;
        public class ExternalProviderSettings
            public string Name { get; set; }
            public bool Enabled { get; set; }
            public List<PropertityInfo> Propertities { get; set; }
            public List<PropertityInfo> SecretPropertities { get; set; }
        public class PropertityInfo
            public string Name { get; set; }
            public string Value { get; set; }
  • 0
    levees created

    Options( the options pattern ) and Setting(Configuration system) are both derived from .net core (extensions) and more powerful

    Settings providers read configuration data from key-value pairs using a variety of configuration sources

    Options uses classes to provide strongly typed access to groups of related settings. is used to configure a group of settings used by the framework services.

    you may define Settings, or derives something from AbpDynamicOptionsManager

    follow the documents: