Open Closed

How to get the danymic option manually? #2800


User avatar
0
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.
 context.Services.AddAuthentication()
            .AddGoogle(GoogleDefaults.AuthenticationScheme, _ => { })
            .WithDynamicOptions<GoogleOptions, GoogleHandler>(
                GoogleDefaults.AuthenticationScheme,
                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.

 [UnitOfWork]
        public virtual async Task<IActionResult> OnGetExternalLoginCallbackAsync(string returnUrl = "", string returnUrlHash = "", string remoteError = null)
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    zhongfang created

    Oh, may I use as below?

    string providers= await this.SettingProvider.GetOrNullAsync("Abp.Account.ExternalProviders");
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    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
        {
            [JsonProperty("name")]
            public string Name { get; set; }
    
            [JsonProperty("enabled")]
            public bool Enabled { get; set; }
    
            [JsonProperty("properties")]
            public List<PropertityInfo> Propertities { get; set; }
    
            [JsonProperty("secretProperties")]
            public List<PropertityInfo> SecretPropertities { get; set; }
        }
    
        public class PropertityInfo
        {
            [JsonProperty("name")]
            public string Name { get; set; }
    
            [JsonProperty("value")]
            public string Value { get; set; }
        }
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    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: https://docs.abp.io/en/abp/latest/Settings https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-6.0

    https://docs.abp.io/en/abp/latest/Options https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-6.0

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.