/// <summary> /// Create an OAuth token provider to authenticate against ArcGIS Online /// </summary> /// <param name="clientId">The Client Id from your API access section of your application from developers.arcgis.com</param> /// <param name="clientSecret">The Client Secret from your API access section of your application from developers.arcgis.com</param> /// <param name="serializer">Used to (de)serialize requests and responses</param> public ArcGISOnlineAppLoginOAuthProvider(String clientId, String clientSecret, ISerializer serializer = null) { if (String.IsNullOrWhiteSpace(clientId) || String.IsNullOrWhiteSpace(clientSecret)) { System.Diagnostics.Debug.WriteLine("ArcGISOnlineAppLoginOAuthProvider not initialized as client Id/secret not supplied."); return; } Serializer = serializer ?? SerializerFactory.Get(); if (Serializer == null) { throw new ArgumentNullException("serializer", "Serializer has not been set."); } OAuthRequest = new GenerateOAuthToken(clientId, clientSecret); _httpClient = HttpClientFactory.Get(); System.Diagnostics.Debug.WriteLine("Created TokenProvider for " + RootUrl); }
internal PortalGatewayBase(Func <ILog> log, string rootUrl, ISerializer serializer = null, ITokenProvider tokenProvider = null, Func <HttpClient> httpClientFunc = null) { if (string.IsNullOrWhiteSpace(rootUrl)) { throw new ArgumentNullException("rootUrl", "rootUrl is null."); } RootUrl = rootUrl.AsRootUrl(); TokenProvider = tokenProvider; Serializer = serializer ?? SerializerFactory.Get(); Guard.AgainstNullArgument("Serializer", Serializer); var httpFunc = httpClientFunc ?? HttpClientFactory.Get; _httpClient = httpFunc(); MaximumGetRequestLength = 2047; _logger = log() ?? LogProvider.For <PortalGatewayBase>(); _logger.DebugFormat("Created new gateway for {0}", RootUrl); }
internal ArcGISOnlineAppLoginOAuthProvider(Func <ILog> log, string clientId, string clientSecret, ISerializer serializer = null) { if (string.IsNullOrWhiteSpace(clientId)) { throw new ArgumentNullException("clientId", "clientId is null."); } if (string.IsNullOrWhiteSpace(clientSecret)) { throw new ArgumentNullException("clientSecret", "clientSecret is null."); } Serializer = serializer ?? SerializerFactory.Get(); Guard.AgainstNullArgument("Serializer", Serializer); OAuthRequest = new GenerateOAuthToken(clientId, clientSecret); _httpClient = HttpClientFactory.Get(); _logger = log() ?? LogProvider.For <ArcGISOnlineAppLoginOAuthProvider>(); _logger.DebugFormat("Created new token provider for {0}", RootUrl); }