Skip to content

Added Proxy Configuration #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Darkpingouin
Copy link

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.

@bounav
Copy link

bounav commented May 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants