AdobeDocs / adobe-dev-console

Apache License 2.0
20 stars 105 forks source link

.NET sample code generates proxy-related error response #53

Closed Trazzmonger closed 1 month ago

Trazzmonger commented 1 year ago

Expected Behaviour

The sample code is supposed to build a JWT object and then pass it in an Adobe API call to get back an "access token".

Actual Behaviour

Such API calls are failing with a response.ErrorMessage of "The remote server returned an error: (407) Proxy Authentication Required."

However, from that error message, I can't tell if the "remote server" is referring to the ims-na1.adobelogin.com site (to which I'm sending the request) or if it's referring to some proxy server of my own company (which might be blocking the request before it even leaves my company's internal network).

Reproduce Scenario (including but not limited to)

Use the sample code to make the API call. NOTE: I successfully get an Access Token when I copy-paste my Adobe API Project's private key into the GUI box provided for such testing at https://developer.adobe.com/console/projects/374378/4566206088344859311/apis/AdobeIOManagementAPISDK/details.

Steps to Reproduce

  1. Prepare the requisite Adobe API "Project" (e.g., https://developer.adobe.com/console/projects/374378/4566206088344859311/overview)
  2. Use that project to provide the necessary arguments for (using the sample code to make a) REST API call ... leveraging an older version of the RestSharp open source library (e.g., v106.13.0) due to another issue (https://github.com/AdobeDocs/adobe-dev-console/issues/50)

Platform and Version

Windows 10 running Microsoft Visual Studio 2019.

Sample Code that illustrates the problem

Current code leveraging an older version of the RestSharp library (e.g., v106.13.0).

Logs taken while reproducing problem

n/a

Trazzmonger commented 1 year ago

I was able to resolve this issue by adding the following additional code: const string proxyAddress = "http://proxy.jpmchase.net:8443";

...and then changing this existing code: var client = new RestClient("https://ims-na1.adobelogin.com/ims/exchange/jwt/"); ...to this instead: var client = new RestClient("https://ims-na1.adobelogin.com/ims/exchange/jwt/") { Proxy = new WebProxy(proxyAddress) };

Since most companies (and surely all large companies) have a proxy server, I strongly recommend you add such code to your sample code (after changing the JPMC-specific proxy server address to something generic, obviously).

theManikJindal commented 1 month ago

Hello, seems like this issue relates to sample code provided for the deprecated Service Account (JWT) credentials. We are no longer enhancing the documentation surrounding the deprecated credentials.