public SquidexClientManager(Uri serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null) { Guard.NotNull(serviceUrl, nameof(serviceUrl)); Guard.NotNull(authenticator, nameof(authenticator)); Guard.NotNullOrEmpty(applicationName, nameof(applicationName)); this.authenticator = authenticator; this.httpConfigurator = httpConfigurator; this.applicationName = applicationName; this.serviceUrl = serviceUrl; this.httpConfigurator = httpConfigurator ?? NoopHttpConfigurator.Instance; }
public SquidexClientManager(Uri serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null) : this(new SquidexOptions { Url = serviceUrl.ToString(), Authenticator = authenticator, AppName = applicationName, Configurator = httpConfigurator }) { }
public SquidexClientManager(string serviceUrl, string applicationName, string clientId, string clientSecret, IHttpConfigurator httpConfigurator = null) : this(new SquidexOptions { Url = serviceUrl, ClientId = clientId, ClientSecret = clientSecret, AppName = applicationName, Configurator = httpConfigurator }) { }
internal void CheckAndFreeze() { if (!Uri.IsWellFormedUriString(url, UriKind.Absolute)) { throw new ArgumentException("URL must be a valid absolute URL."); } url = url.TrimEnd('/', ' '); if (string.IsNullOrWhiteSpace(appName)) { throw new ArgumentException("App name is not defined."); } if (!string.IsNullOrWhiteSpace(assetCDN)) { if (!Uri.IsWellFormedUriString(assetCDN, UriKind.Absolute)) { throw new ArgumentException("Asset CDN URL must be absolute if specified."); } contentCDN = contentCDN.TrimEnd('/', ' '); } if (!string.IsNullOrWhiteSpace(contentCDN)) { if (!Uri.IsWellFormedUriString(contentCDN, UriKind.Absolute)) { throw new ArgumentException("Content CDN URL must be absolute if specified."); } assetCDN = assetCDN.TrimEnd('/', ' '); } if (authenticator == null) { if (string.IsNullOrWhiteSpace(clientId)) { throw new ArgumentException("Client id is not defined."); } if (string.IsNullOrWhiteSpace(clientSecret)) { throw new ArgumentException("Client secret is not defined."); } var cache = new MemoryCache(Options.Create(new MemoryCacheOptions())); authenticator = new CachingAuthenticator($"TOKEN_{Url}", cache, new Authenticator(Url, clientId, clientSecret)); } if (configurator == null) { configurator = NoopHttpConfigurator.Instance; } if (clientFactory == null) { clientFactory = NoopHttpConfigurator.Instance; } if (httpClientTimeout == TimeSpan.Zero) { httpClientTimeout = TimeSpan.FromSeconds(100); } isFrozen = true; }
public SquidexClientManager(string serviceUrl, string applicationName, IAuthenticator authenticator, IHttpConfigurator httpConfigurator = null) : this(new Uri(serviceUrl, UriKind.Absolute), applicationName, authenticator, httpConfigurator) { }
public SquidexClientManager(string serviceUrl, string applicationName, string clientId, string clientSecret, IHttpConfigurator httpConfigurator = null) : this(new Uri(serviceUrl, UriKind.Absolute), applicationName, new CachingAuthenticator($"TOKEN_{serviceUrl}", new MemoryCache(Options.Create(new MemoryCacheOptions())), new Authenticator(serviceUrl, clientId, clientSecret)), httpConfigurator) { }