using Microsoft.Extensions.Configuration; namespace Dilon.Core.OAuth { /// /// OAuth配置---此结构方便拓展 /// public class OAuthConfig { /// /// AppId /// public string AppId { get; set; } /// /// Secret Key /// public string AppKey { get; set; } /// /// 回调地址 /// public string RedirectUri { get; set; } /// /// 权限范围 /// public string Scope { get; set; } public static OAuthConfig LoadFrom(IConfiguration configuration, string prefix) { return With(appId: configuration[prefix + ":app_id"], appKey: configuration[prefix + ":app_key"], redirectUri: configuration[prefix + ":redirect_uri"], scope: configuration[prefix + ":scope"]); } private static OAuthConfig With(string appId, string appKey, string redirectUri, string scope) { return new OAuthConfig() { AppId = appId, AppKey = appKey, RedirectUri = redirectUri, Scope = scope }; } } }