ebay-oauth-csharp-client
ebay-oauth-csharp-client copied to clipboard
Added Proxy Configuration
I had trouble getting the Access Token and found out that the RestClient had no way to configure an IWebProxy. So I added ProxyUtil to configure our proxy and now it works properly.
I added the usage in the README but if you want I can put it in a special section of the README instead.
I think you are touching on something quite important here. The HTTP client (restsharp in that case) is hardcoded in OAuth2Api.cs.
See line 241 of OAuth2Api.cs)
// Initialize client
RestClient client = new RestClient
{
BaseUrl = new Uri(environment.ApiEndpoint())
};
This means you can't configure a proxy client or change anything, be it the proxy settings or the request timeout...
Instead of adding more hardcoded stuff to handle a the configuration of a proxy, I would suggest adding a simple http client dependency to the OAuth2Api class.
public interface IRestClientFactory
{
RestClient Create();
}
We could then have a default implementation of that http client factory that give a new instance of RestClient set with the base URL (as above), but then if you want you can change the default implementation an inject another client configured to use a proxy.