public Connectors(IUrls urls, OAuth2Client.IStorage storage) { if (urls == null) throw new ArgumentNullException("urls"); if (storage == null) throw new ArgumentNullException("storage"); _urls = urls; _storage = storage; InitializeInternal(); }
public V1APIConnector(string urlPrefix, string username = null, string password = null, bool?integratedAuth = null, ProxyProvider proxy = null, OAuth2Client.IStorage storage = null) : base(urlPrefix, new CredentialCache(), proxy) { var cache = _creds as CredentialCache; var uri = new Uri(urlPrefix); // Try the OAuth2 credential OAuth2Client.IStorage oauth2storage = null; if (storage != null) { oauth2storage = storage; } else { try { var s = OAuth2Client.Storage.JsonFileStorage.Default as OAuth2Client.IStorage; s.GetSecrets(); oauth2storage = s; } catch (System.IO.FileNotFoundException) { // swallowed - meaning no oauth2 secrets configured. } } if (oauth2storage != null) { cache.Add(uri, "Bearer", new OAuth2Client.OAuth2Credential( "apiv1", oauth2storage, proxy != null ? proxy.CreateWebProxy() : null ) ); } if (username == null) { if (integratedAuth.GetValueOrDefault(true)) { // no constructor args - so use default integrated identity unless they say no. cache.Add(uri, "NTLM", CredentialCache.DefaultNetworkCredentials); cache.Add(uri, "Negotiate", CredentialCache.DefaultNetworkCredentials); } } else { var userPassCred = new NetworkCredential(username, password); cache.Add(uri, "Basic", userPassCred); if (!integratedAuth.GetValueOrDefault(false)) { // If there's a username, we'll assume the user doesn't want Windows Auth unless they ask. cache.Add(uri, "NTLM", userPassCred); cache.Add(uri, "Negotiate", userPassCred); } } }
public IServices CreateServices(string baseUrl, OAuth2Client.IStorage storage) { var dataConnector = new V1APIConnector(baseUrl + "/rest-1.v1/", userName, password, integratedAuth); var metaConnector = new V1APIConnector(baseUrl + "/meta.v1/"); _metaModel = new MetaModel(metaConnector); var services = new Services(_metaModel, dataConnector); return(services); }
/// <summary> /// Initialize a V1Instance that uses OAuth2 to authenticate to the backend server. /// </summary> /// <param name="applicationPath"></param> /// <param name="oauth2storage"></param> public V1Instance(string applicationPath, OAuth2Client.IStorage oauth2storage) { if (!applicationPath.EndsWith("/")) { applicationPath += "/"; } apiClientInternals = new ApiClientInternals(applicationPath, oauth2storage, null); wrapperManager = new WrapperManager(this); }
public IServices CreateServices(string baseUrl, OAuth2Client.IStorage storage) { var dataConnector = new V1OAuth2APIConnector(baseUrl + "/rest-1.oauth.v1/", storage); var metaConnector = new V1OAuth2APIConnector(baseUrl + "/meta.v1/", storage); _metaModel = new MetaModel(metaConnector); var services = new Services(_metaModel, dataConnector); return(services); }
public Connectors(IUrls urls, OAuth2Client.IStorage storage) { if (urls == null) { throw new ArgumentNullException("urls"); } if (storage == null) { throw new ArgumentNullException("storage"); } _urls = urls; _storage = storage; InitializeInternal(); }
/// <summary> /// Initialize a V1Instance that uses OAuth2 to authenticate to the backend server and communicates via a proxy /// </summary> /// <param name="applicationPath"></param> /// <param name="oauth2storage"></param> /// <param name="proxySettings"></param> public V1Instance(string applicationPath, OAuth2Client.IStorage oauth2storage, ProxySettings proxySettings) { if (!applicationPath.EndsWith("/")) { applicationPath += "/"; } ProxyProvider proxyProvider = null; if (proxySettings != null) { proxyProvider = new ProxyProvider(proxySettings.Path, proxySettings.Username, proxySettings.Password, proxySettings.Domain); } apiClientInternals = new ApiClientInternals(applicationPath, oauth2storage, proxyProvider); wrapperManager = new WrapperManager(this); }