1

In UPS OAuth API integration, we are getting a timeout on API response. When we try a request with CURL, we are getting a http 302 successful response. But in RestSharp / C#, we get timeout.

C# code:

var restClient = new RestClient("https://onlinetools.ups.com/security/v1/oauth/authorize");
var request = new RestRequest(Method.GET);
request.AddQueryParameter("client_id", "MyclientId");
request.AddQueryParameter("redirect_uri", "https://local.myclient.com/Seller/Carrier/UpsOAuthCallback");
request.AddQueryParameter("response_type", "code");
request.AddQueryParameter("scope", "read");
request.AddQueryParameter("state", "superstate");
request.AddQueryParameter("code_challenge", "boxes2021");

var response = await restClient.ExecuteAsync(request);

CURL command:

curl -v -i -X GET 'https://onlinetools.ups.com/security/v1/oauth/authorize?client_id=MyclientId&redirect_uri=https://local.myclient.com/Seller/Carrier/UpsOAuthCallback&response_type=code&state=superstate&scope=read&code_challenge=boxes@2021'

I've tried a code block for OAuth and I got timeout. But when I tried the request with CURL in the terminal, I got a successful response.

1 Answer 1

0

You sholud to use redirect=false

var client = new RestClient("https://onlinetools.ups.com")
{
    FollowRedirects = false
};

var request = new RestRequest("/security/v1/oauth/authorize", Method.Get);

request.AddParameter("client_id", "my_client_id");
request.AddParameter("redirect_uri", "https://localhost.blabla.com/Seller/Carrier/UpsOAuthCallback");
request.AddParameter("response_type", "code");
request.AddParameter("state", "superstate");
request.AddParameter("scope", "read");
request.AddParameter("code_challenge", "boxes2021");

var response = await client.ExecuteAsync(request);

Console.WriteLine("Status Code: " + response.StatusCode);
Console.WriteLine("Response Content: " + response.Content);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.