From e56accf8558c6b73c94accf966bc20c9db8a7e98 Mon Sep 17 00:00:00 2001 From: Aurelie Orset Date: Wed, 20 Jan 2021 09:54:52 +0100 Subject: [PATCH 1/2] Added Proxy Configuration --- .../eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs | 9 +++++++++ .../eBay/ApiClient/Auth/OAuth2/ProxyUtil.cs | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/ProxyUtil.cs diff --git a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs index d33496f..90bde9c 100644 --- a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs +++ b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/OAuth2Api.cs @@ -243,6 +243,15 @@ private OAuthResponse FetchToken(OAuthEnvironment environment, String requestPay BaseUrl = new Uri(environment.ApiEndpoint()) }; + //Get proxy + IWebProxy proxy = ProxyUtil.WebProxy; + + //Initialize proxy + if (proxy != null) + { + client.Proxy = proxy; + } + //Create request RestRequest request = new RestRequest(Method.POST); diff --git a/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/ProxyUtil.cs b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/ProxyUtil.cs new file mode 100644 index 0000000..f21a7ab --- /dev/null +++ b/ebay-oauth-csharp-client/eBay/ApiClient/Auth/OAuth2/ProxyUtil.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; + +namespace eBay.ApiClient.Auth.OAuth2 +{ + public static class ProxyUtil + { + public static IWebProxy WebProxy; + } +} + From 1672fe10eb31227cddf60dd3eb0812ea401d5a22 Mon Sep 17 00:00:00 2001 From: Darkpingouin Date: Wed, 20 Jan 2021 09:59:06 +0100 Subject: [PATCH 2/2] Update README.adoc --- README.adoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.adoc b/README.adoc index f17e7cb..50479f2 100644 --- a/README.adoc +++ b/README.adoc @@ -88,6 +88,12 @@ CredentialUtil.Load(“YAML config file path”); or CredentialUtil.Load(System.IO.StreamReader); +- If needed, you can add an IWebProxy. +[source,csharp] +IWebProxy webProxy = new WebProxy(); +//Your configuration here +ProxyUtil.WebProxy = webProxy; + - Once the credentials are loaded, call any operation on **OAuth2Api**. 1. **GetApplicationToken**: Use this operation when the application request an access token to access their own resources, not on behalf of a user. Learn more about https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html[Client Credentials grant flow].