示例#1
0
        protected AbstractClientProvider(WebConfiguration ccRoot, OAuthSettingsConfig ccOauth)
        {
            ClientId     = ccOauth.ClientId;
            ClientSecret = ccOauth.ClientSecret;
            CallBackUrl  = ccOauth.CallbackUrl;
            Scope        = ccOauth.Scope;
            Endpoint     = ccOauth.Endpoint;

            AcceptedRedirectUrl = ccRoot.AcceptedRedirectUrl;
            FailedRedirectUrl   = ccRoot.FailedRedirectUrl;
            Proxy = ccRoot.Proxy;
        }
示例#2
0
        public static T CreateClient <T>(string appName, string configName) where T : AbstractClientProvider, new()
        {
            if (String.IsNullOrEmpty(appName))
            {
                throw new Exception("ERROR: AppName cannot be null!");
            }
            if (String.IsNullOrEmpty(configName))
            {
                throw new Exception("ERROR: ConfigName cannot be null!");
            }

            var ccRoot = OAuth2LoginConfig.Instance;

            if (ccRoot != null)
            {
                WebConfiguration ccWebElem = ccRoot.Web;
                OAuthConfig      ccAppElem = OAuth2LoginConfig.Instance.OAuth.GetItemByKey(appName);
                if (ccAppElem == null)
                {
                    throw new Exception($"ERROR: AppName[{appName}] in OAuth2Login.Configuartion is not found!");
                }

                OAuthSettingsConfig ccOauth = ccAppElem.OAuthSettings.GetItemByKey(configName);

                if (ccOauth == null)
                {
                    throw new Exception($"ERROR: ConfigurationName[{configName}] in OAuth2Login.Configuartion is not found!");
                }

                var constructorParams = new object[]
                {
                    ccWebElem,
                    ccOauth
                };
                var client = (T)Activator.CreateInstance(typeof(T), constructorParams);

                return(client);
            }

            return(default(T));
        }
示例#3
0
 public PayPalClient(WebConfiguration ccRoot, OAuthSettingsConfig ccOauth)
     : base(ccRoot, ccOauth)
 {
 }
示例#4
0
 public WindowsLiveClient(WebConfiguration ccRoot, OAuthSettingsConfig ccOauth)
     : base(ccRoot, ccOauth)
 {
 }
 public TwitterClient(WebConfiguration ccRoot, OAuthSettingsConfig ccOauth)
     : base(ccRoot, ccOauth)
 {
 }
示例#6
0
 public FacebookClient(WebConfiguration ccRoot, OAuthSettingsConfig ccOauth)
     : base(ccRoot, ccOauth)
 {
 }